表达骆驼路线的最佳方式

3 apache-camel

如果X为假,我想路由到A,如果X为真,我想路由到A和B.

我试着写一些类似的东西

from(?)
.choice()
   .when( X )
      .multicast().to(A,B).end()
   .otherwise() // I get a (compile) error underlined here saying 'otherwise() is not on type ProcessorDefinition
      .to( A )
Run Code Online (Sandbox Code Playgroud)

它不喜欢它我怀疑这不是表达这一点的最佳方法

基本上我总是想路由到(A),如果那个条件在那里我也想路由到(B)

在Camel中表达这个的最佳方式是什么?

Ben*_*Day 6

endChoice()在你的when()条款结尾处使用它会起作用......

请参阅http://camel.apache.org/why-can-i-not-use-when-or-otherwise-in-a-java-camel-route.html

  • 如果命名为"endWhen",那么`endChoice`可能会更加不言自明. (6认同)