First, yes, I have searched and, yes, I have read the same Apache document every one points to. :-) I think there is a bit of confusion and I think I know an answer, so let me lay out an example of what I thought was correct, follow it with what I think the answer is. Thanks. Oh, and I do know that some of the endChoice() lines are not strictly necessary and that Camel will figure it out, but I like the blocks to be cleanly delineated, unless there is some reason not to use them.
.choice()
.when(X1)
// do stuff
.choice()
.when(Y)
//do more stuff
.endChoice() // close inner when block
.end() // close inner choice block
.endChoice() // close first outer when
.when(X2)
// do other stuff
.endChoice() // close second outer when
.end() // close outer choice
So, my original look at the API, I thought that end() was for closing things like choice and split and that endChoice() was for closing choice options like when and otherwise. It looks more like the latter is actually an end() that returns a ChoiceDefinition. Which makes the name a little better.
But, if I take out the end() labeled 'close inner choice block', this means I carry on to the next line, an endChoice(). Does this then close the inner choice block? Given that, the when(X2) is still within the the when(X1) block. So, I think that I need to replace the end() with an endChoice() rather than removing it. So the result would look like:
.choice()
.when(X1)
// do stuff
.choice()
.when(Y)
//do more stuff
.endChoice() // close inner when block
.endChoice() // close inner choice block
.endChoice() // close first outer when
.when(X2)
// do other stuff
.endChoice() // close second outer when
.end() // close outer choice
So is this the way to handle this in Camel? Or is there a simpler way that I am just missing? Thanks for your time.