Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way of expressing Camel route

Tags:

apache-camel

If X is false I want to route to A, if X is true I want to route to A and B

I tried to write something like

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 )

it doesn't like it I suspect this isn't the best way of phrasing this

basically I always want to route to (A) and if that condition is there I also want to route to (B)

what is the best way of expressing this in Camel?


1 Answers

use endChoice() at the end of your when() clause and it'll work...

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

like image 131
Ben ODay Avatar answered Nov 26 '25 15:11

Ben ODay