【发布时间】:2020-03-05 08:02:01
【问题描述】:
我希望子路由从 Timer 路由运行,但以下代码运行不正常:
子路由:
from("direct:processOrder").id("dd")
// .setBody(constant("select * from customer"))
// .to("jdbc:testdb")
.to("sql:select * from EMPLOYEE?dataSource=masterdata")
.log(LoggingLevel.INFO, "DB")
.to("log:?level=INFO&showBody=true").end();
主要路线:
from("timer://foo?period=30000")
.log(LoggingLevel.INFO, "Triggered Company")
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getContext().startRoute("dd");
}
})
.end();
输出:
20/03/05 13:28:07 INFO impl.DefaultCamelContext: StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
20/03/05 13:28:08 INFO impl.DefaultCamelContext: Route: dd started and consuming from: Endpoint[direct://processOrder]
20/03/05 13:28:08 INFO impl.DefaultCamelContext: Route: route1 started and consuming from: Endpoint[timer://foo?period=30000]
20/03/05 13:28:08 INFO impl.DefaultCamelContext: Total 2 routes, of which 2 is started.
20/03/05 13:28:08 INFO impl.DefaultCamelContext: Apache Camel 2.15.1 (CamelContext: camel-1) started in 0.400 seconds
20/03/05 13:28:09 INFO route1: Triggered Company
20/03/05 13:28:09 INFO impl.DefaultCamelContext: Route: dd started and consuming from: Endpoint[direct://processOrder]
要在子路由的from 中使用什么组件,以便在我们从主路由程序.startRoute 时运行?
【问题讨论】:
标签: java apache-camel camel-sql camel-jdbc