Since we're on a major migration process of this website, some component documents here are out of sync right now. In the meantime you may want to look at the early version of the new website
We would very much like to receive any feedback on the new site, please join the discussion on the Camel user mailing list.
Why can I not use when/otherwise in a Java Camel route?
When using the Content Based Router in the Java DSL you may have a situation where the compiler will not accept the following when() or otherwise() statement.
Well the first issue is that the Load Balancer uses the additional routing to know what to use in the load balancing. In this example that would be the:
To indicate when the balancing stops, you should use
But the code will still not compile. The reason is we have stretched how far we can take the good old Java language in terms of DSL. In a more modern language such as Scala or Groovy you would be able to let it be stack based, so the
You only need to use
If there is still problems, then you can split your route into multiple routes, and link them together using the Direct component.