Reputation: 91
Hi I'm trying to make a While in ESB, but there isn't a While Mediator, I tried to break a foreach with a loopback when it found the right value and it works but this action takes me to the outSequence, not allowing me to continue working in the inSequence, any suggestion?
Thanks in advance.
Upvotes: 0
Views: 474
Reputation: 499
You can have a work around like this;
<!-- Assume that we have to iterate through 'items' array, "items" :[....] and 'noOfItems' property will hold the number of iterations. -->
<property name="noOfItems" expression="count(//items)" scope="operation" />
<property name="itemIndex" expression="0" scope="operation" />
<iterate continueParent="false" id="stories" expression="//items" sequential="false" preservePayload="false">
<target>
<sequence>
<!-- Your iteration logic -->
</sequence>
</target>
</iterate>
<!-- Move to outSequence if use "<loopback />" or include any post iteration logic when all the iterations are done. -->
<filter xpath="get-property('operation', 'itemIndex') = get-property('operation', 'noOfItems')">
<then>
<!-- to move outSequence -->
<loopback />
</then>
</filter>
Upvotes: 1