Java 动态从Apache Camel RouteBuilder生成多个

Java 动态从Apache Camel RouteBuilder生成多个,java,apache-camel,Java,Apache Camel,我使用的是camel core 2.24.1,能够做到以下几点: from(sources.toArray(新字符串[0])) 其中sources是我从配置设置中获取的URI列表。我正在尝试更新代码以使用Camel 3(Camel core 3.0.0-RC2),但上面提到的方法已被删除,我无法找到其他方法来完成相同的操作 基本上我需要这样的东西: from( String uri : sources ) { // add the uri as from(uri) before cont

我使用的是camel core 2.24.1,能够做到以下几点:

from(sources.toArray(新字符串[0]))
其中sources是我从配置设置中获取的URI列表。我正在尝试更新代码以使用Camel 3(Camel core 3.0.0-RC2),但上面提到的方法已被删除,我无法找到其他方法来完成相同的操作

基本上我需要这样的东西:

from( String uri : sources )
{
   // add the uri as from(uri) before continuing with the route
}
如果这有助于更好地理解,则最终路线应如下所示:

from(sources.toArray(新字符串[0]))
.routeId(常数.ROUTE_ID)
.split().method(WorkRequestSplitter.class,“splitMessage”)
.id(常数.工作\请求\拆分器\ id)
.split()方法(RequestSplitter.class,“splitMessage”)
.id(常量.请求\u拆分器\u id)
.choice()
.when(useReqProc)
.log(LoggingLevel.INFO,“找到使用它的请求处理器”)
.to(“bean:+reqName)
.endChoice()
.否则()
.log(LoggingLevel.ERROR,“找不到requestProcessor,正在停止路由”)
.停止
.endChoice()
(完)
.log(“将请求发送到URI”)
.recipientList(标题(Constants.HDR\u ARES\u URI))
.choice()
.when(useResProc)
.log(LoggingLevel.INFO,“找到使用它的结果处理器”)
.to(“bean:+resName)
.endChoice()
.否则()
.log(LoggingLevel.INFO,“未找到resultProcessor,按原样发送”)
.endChoice()
(完)
.log(“向所有侦听器发送请求”)
.to(this.destinations.toArray(新字符串[0]);

任何帮助都将不胜感激。

此功能已在中删除,没有直接替换

见:

在Camel 2.x中,您可以有2个或更多的Camel路由输入,但是Camel中的所有用例都不支持这一点,而且很少使用此功能。在Camel 2.x中,这也被弃用。在Camel 3中,我们删除了为路由指定多个输入的剩余代码,现在只可能为路由指定一个输入

始终可以使用将管线定义拆分为逻辑块。这也可以通过for each动态生成

for(String uri : sources){
    from(uri).to("direct:commonProcess");
}

from("direct:commonProcess")
    .routeId(Constants.ROUTE_ID)
    //...
    .log("Sending the request to all listeners")
    .to(this.destinations.toArray(new String[0]));