I want to exit from Camel Loop at some condition. I am using Camel 2.15
.loop(simple("${exchangeProperty.loopCount}"))
.to("bean:xxx?method=exitFromLoop")
.end()
I tried changing CamelLoopIndex and CamelLoopSize in exitFromLoop method, but didn't worked for me.
Is there any alternative to this e.g using choice/when?
There is a loop while mode if you use Camel 2.17 onwards.
See the documentation: http://camel.apache.org/loop
Then the loop runs like a while loop until the predicate evaluates to false / null or zero.
As its a predicate it does not automatic decrement a counter, so its like a while loop in java.