Direct
当生产者发送消息交换时,Direct 组件提供对任何消费者的直接、同步调用。
此端点可用于连接同一Camel 上下文中的现有路由。
示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| @Test public void testDirect() throws Exception {
CamelContext context=new DefaultCamelContext();
context.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:home") .process(exchange -> { System.out.println("process:"+exchange.getIn().getBody()); }); } }); context.start(); context.createProducerTemplate().sendBody("direct:home","hello"); Thread.sleep(2000); }
|
ProducerTemplate