Mule for each scope headerc ollection
-
Upload
phaniu -
Category
Technology
-
view
192 -
download
0
Transcript of Mule for each scope headerc ollection
![Page 1: Mule for each scope headerc ollection](https://reader036.fdocuments.us/reader036/viewer/2022092621/5880b1081a28abf32c8b6559/html5/thumbnails/1.jpg)
Mule For Each Scope – Header Collection
![Page 2: Mule for each scope headerc ollection](https://reader036.fdocuments.us/reader036/viewer/2022092621/5880b1081a28abf32c8b6559/html5/thumbnails/2.jpg)
• In this slide deck we will see how Foreach processes a collection in message header
![Page 3: Mule for each scope headerc ollection](https://reader036.fdocuments.us/reader036/viewer/2022092621/5880b1081a28abf32c8b6559/html5/thumbnails/3.jpg)
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](https://reader036.fdocuments.us/reader036/viewer/2022092621/5880b1081a28abf32c8b6559/html5/thumbnails/4.jpg)
• 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](https://reader036.fdocuments.us/reader036/viewer/2022092621/5880b1081a28abf32c8b6559/html5/thumbnails/5.jpg)
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](https://reader036.fdocuments.us/reader036/viewer/2022092621/5880b1081a28abf32c8b6559/html5/thumbnails/6.jpg)
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](https://reader036.fdocuments.us/reader036/viewer/2022092621/5880b1081a28abf32c8b6559/html5/thumbnails/7.jpg)