Search code examples
mulemulesoftmule-esb

How to overcome fire and forget problem in foreach loop mule 3


Send the incoming payload to the foreach loop ,After the foreach loop can't get the response payload from the foreach loop.

enter image description here


Solution

  • For the Foreach loop ,after the each loop the response payload is forgot. It seems Fire and Forgot.

    To overcome this Fire and Forgot ,we need to store the response payload after the each iteration.

    1. Create a Flow variable with empty payload.

    enter image description here

    1. Create a Transform message inside the Foreach loop. Click the Edit current target icon in Transform message and change the output type to variable and enter the variable name, then append the response payload for each iteration to the output variable by flowVars.output + payload .

    enter image description here

    1. Create the Transform message after the foreach loop. Finally Print the Response payload by flowVars.output .

    enter image description here

    Hope Its Help.