Camel to 运行 standalone 路由中是否有可用的组件?

Is there any component available in Camel to run standalone route?

我想要一条从计时器路由到 运行 的子路由,但以下代码未正确 运行ning:

子路由:

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 时它只是 运行s?

参见direct component。使用 "to" 而不是 ".process":

.to("direct:processOrder");

根据您的日志,两条路由均已正确启动,因此您无需明确执行 .startRoute

要将信号传递到另一条路线,请在您的父路线中调用 .to("direct:processOrder") 而不是 运行 您现在拥有的处理器:

from("timer://foo?period=30000")
  .log(LoggingLevel.INFO, "Triggered Company")
  .to("direct:processOrder")
  .end()