Reputation: 645
I have a for each loop in my Mule 3 flow.
The Collection for the same is a flow variable array as shown below:
"[
"Alpha",
"Bravo",
"Charlie",
"Delta",
"Echo",
]"
Inside the for each, I have a session variable to store the current array value. I have set the value as #[payload]. The idea is to use each iterated ID to make an API update call. The issue is that, I am getting the complete payload as the current id session variable (as opposed to a single value). Any idea why it's not iterating 5 times (5 is the number of IDs that I have in the array).
Upvotes: 0
Views: 853
Reputation: 2650
i couldnt reproduce your error. may be the way your array variable is defined is not proper. i am not sure. I did a slight change.
<flow name="loos_sample" doc:id="25ef89d0-dfcd-48c3-8c66-a94373a3b46c" >
<http:listener doc:name="Listener" doc:id="96eca53c-6976-4b0e-9a18-9fd6d0ee6520" config-ref="HTTP_Listener_config" path="/loop"/>
<ee:transform doc:name="Transform Message" doc:id="2ea9d7e3-ff1c-4ba4-99f2-40ae4c2d16e7" >
<ee:message >
</ee:message>
<ee:variables >
<ee:set-variable variableName="varIds" ><![CDATA[%dw 2.0
output application/java
---
{ arr:
[
"Alpha",
"Bravo",
"Charlie",
"Delta",
"Echo",
]
}]]></ee:set-variable>
</ee:variables>
</ee:transform>
<foreach doc:name="For Each" doc:id="972ee8d5-d8d6-43b6-866a-0894d1b3a450" collection="#[vars.varIds.arr]">
<logger level="INFO" doc:name="Logger" doc:id="4478c587-f01c-4e2a-9485-5aa4b1be11df" message="curernt item: #[payload]"/>
</foreach>
</flow>
Upvotes: 1