我使用的是camel-core 2.24.1并且能够执行以下操作:
from( sources.toArray(new String[0]) )
Run Code Online (Sandbox Code Playgroud)
其中,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
}
Run Code Online (Sandbox Code Playgroud)
如果这有助于更好地理解,最终路线应如下所示:
from( String uri : sources )
{
// add the uri as from(uri) before continuing with the route
}
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激。
此功能在CAMEL-6589 中被删除,没有直接替换。
请参阅迁移指南:
在 Camel 2.x 中,您可以有 2 个或更多 Camel 路由的输入,但并非 Camel 的所有用例都支持此功能,并且此功能很少使用。这在 Camel 2.x 中也已被弃用。在 Camel 3 中,我们删除了用于指定路由的多个输入的剩余代码,现在只能为路由指定仅 1 个输入。
您始终可以使用Direct endpoint将路由定义拆分为逻辑块。这也可以使用 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]));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
889 次 |
| 最近记录: |