I want to have
_ from( A )
_ .split()...
_ .choice() //Choice 1
_ .when( predicate )
_ .process()
_ .choice() // Choice 2
_ .when( x )
_ .to( X )
_ .otherwise()
_ .to( Y )
_ .end() // to terminate inner choice
_ .endchoice() // tell camel we're back in the outer-choice - gets exception
_ .otherwise() // Choice 1
_ .to( Z )
_ .end()
but I get runtime exception on the endChoice()
java.lang.ClassCastException: org.apache.camel.model.SplitDefinition cannot be cast to org.apache.camel.model.ChoiceDefinition
I get compile time error without it
I suspect end() is ending the inner and outer choice, I only want it to end the inner one.
not putting in the end() makes it treat the second otherwise() as an extension of the inner-choice. Which it isn't.
I have found workaround by putting the second choice in a sub-route and "direct:SUB_ROUTE"-ing into it, but I would prefer to use the plainer structure I've outlined above if I could. Is there a way to achieve Choices in Choices or is this just a limitation of the Java DSL?
not putting in the end() makes it treat the second otherwise() as an extension of the inner-choice. Which it isn't.
Are you sure about that? Infact, I think removing the end() from there should resolve your problem. The endchoice() is enough to indicate the end of the inner choice construct.
I did try a sample code with it and it was working fine..
Thanks!