I need to iterate over a list of items in a route. And inside that route I again have to iterate over a list of items.
I'm using loop
for that, and for getting to know the current iteration using the CamelLoopIndex
property.
The problem here is, suppose the outer loop has 50 items to iterate over and the inner loop has 3 items to iterate over. What happens is, after the first iteration of the outer loop it directly skips to the fourth iteration as the inner loop sets the CamelLoopIndex
to 2.
I've done a workaround for this:
<outerLoop>
<!-- do some stuff -->
<!-- set the CamelLoopIndex value in a custom exchange property -->
<innerLoop>
<!-- do some other stuff -->
</innerloop>
<!-- reset the CamelLoopIndex value with the one in our custom exchange property -->
</outerloop>
Is there any better way to do this?
loop
– arshad.xyz Feb 18 '17 at 18:17