For-each Scope
Overview
● It is simillar to the for-each present in java, which is used for iterating
purpose over a collection or and array of objects
● It can iterate over elements from any type of collection, including maps, list
even MuleMessageCollecctions
● The ForEach scope can split and proccess collection of elements that are
not part of the message payload, it can also process message property
collection (metadata) from the message header
●
It is necessary to check that only java objects are beinged passed in the
ForEach scope
●
The advantage of using ForEach scope over scatter-aggrigate is that it does
not re-aggrigate the messages in MuleMessageCollection, it will returen the
message in the datatype in which it was sent i.e. the results are always “java-
in.java-out”
Example
● Here we will be passing JSON data which contains array of Students
● For the JSON data to be converted into java object we have used JSON-to-Object
transformer
JSON data
XML of the given flow
XML of the given flow

ForEach scope

  • 1.
  • 2.
    Overview ● It issimillar to the for-each present in java, which is used for iterating purpose over a collection or and array of objects ● It can iterate over elements from any type of collection, including maps, list even MuleMessageCollecctions ● The ForEach scope can split and proccess collection of elements that are not part of the message payload, it can also process message property collection (metadata) from the message header ● It is necessary to check that only java objects are beinged passed in the ForEach scope ● The advantage of using ForEach scope over scatter-aggrigate is that it does not re-aggrigate the messages in MuleMessageCollection, it will returen the message in the datatype in which it was sent i.e. the results are always “java- in.java-out”
  • 3.
    Example ● Here wewill be passing JSON data which contains array of Students ● For the JSON data to be converted into java object we have used JSON-to-Object transformer
  • 4.
  • 5.
    XML of thegiven flow
  • 6.
    XML of thegiven flow