Mule for each scope headerc ollection

7
Mule For Each Scope – Header Collection

Transcript of Mule for each scope headerc ollection

Page 1: Mule for each scope headerc ollection

Mule For Each Scope – Header Collection

Page 2: Mule for each scope headerc ollection

• In this slide deck we will see how Foreach processes a collection in message header

Page 3: Mule for each scope headerc ollection

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

Page 4: Mule for each scope headerc ollection

• 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

Page 5: Mule for each scope headerc ollection

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

Page 6: Mule for each scope headerc ollection

Flow:

We used Java component ‘QueryParamsToList’ immediately after HTTP Listener to convert query parmas to a List.

Output:

Page 7: Mule for each scope headerc ollection