1. Mule For Each Scope – Header Collection
By Ram Bavireddi
2. • In this slide deck we will see how Foreach processes a
collection in message header
3. Message Header Collection
Let us write a Mule flow which listens on HTTP Listener and let
us test the flow with below url having a list of query params
http://localhost:8081/foreach-headertest?names=Ram,Amar,Nag
The value of the query parmater “names” is a list of comma
separated values.
We want to process this list using Foreach scope
4. • Mule HTTP Listener converts query parameters into a
Map. We can access these query parameters using the key
‘http.query.params’
• In our case the query parameter is a comma seperated
values
• We need to convert the comma seperated values to a
List, then we can apply Foreach scope. For this purpose we
nee to write a Java component
5. The Java component which converts comma seperated
values to a List
We use this Java component in our flow to convert
query parameters to a List
6. Flow:
We used Java component ‘QueryParamsToList’ immediately
after HTTP Listener to convert query parmas to a List.
Output: