I have been using dynamic router to solve similar problems (doing pagination) and it ended up really neat. http://camel.apache.org/dynamic-router.html
The idea is to keep redirecting the exchange to the same endpoint and when it's done, you can redirect it either to a success or failure endpoint, keeping state in the exachange and calculating your next endpoint in java code. Micael. -----Original Message----- From: Peck, Sean [mailto:pec...@upmc.edu] Sent: Monday, April 8, 2019 9:47 AM To: users@camel.apache.org Subject: Better way to run a loop until a complete state, or no more than X times? I am trying to set up a loop in camel that will run until a successful state is reached, or no more than 5 tries if it is not. I have it working with the following: . setProperty(“loop”, constant(1)) .loopDoWhile(simple("${property.loop} != 0 && ${property.CamelLoopIndex} != 5) //actual work .when( successfully finished). setProperty(“loop”, constant(0)) .end This does work, but then I need to decide after the loop is finished, did it successfully do what it needed to do or did it error out. Which adds another choice, etc after the loop to conditionalize my next step, depending on why the loop exited. While this does work, this seems very kludgy and adds a lot of conditionals to the route. Is there a more “camelish” way to accomplish this run this loop until a condition is met, or X number of times? -- Sean Peck UPMC Enterprises Lead Software Engineer pec...@upmc.edu<mailto:pec...@upmc.edu> 412 647 5624 “The answer is a question that I never will find out.”