Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exit from Apache Camel loop

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?

like image 346
Honey Goyal Avatar asked Jan 20 '26 19:01

Honey Goyal


1 Answers

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.

like image 118
Claus Ibsen Avatar answered Jan 23 '26 09:01

Claus Ibsen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!