Scatter Gather 


Scatter Gather in MuleSoft

  • The ScatterGather component executes each route in parallel.
  • Each route receives a reference to the Mule event and executes a sequence of one or more event processors.
  • Each of these routes uses a separate thread to execute the event processors, and the resulting Mule event can be either the same Mule event without modifications or a new Mule event with its own payload, attributes, and variables.The Scatter-Gather component then combines the Mule events returned by each processing route into a new Mule event that is passed to the next event processor only after every route completes successfully
  • Scatter-Gather component to have at least two routes; otherwise, your Mule application throws an exception and does not start.
  • Use Try scope in each route of a ScatterGather component to handle any errors that might be generated by a route’s event processors

In this tutorial I will invoke 2 different Database Tables in parallel using scatter gather and it will give the new mule event with the result of 2 Database calls

Create a project in anypoint studio and configure the listener to trigger the flow

Drag and drop scatter gather and configure the 2 Select Operation

Scatter Gather


Two select operation will fetch the data from two different database table

Scatter Gather


Second select statement

Scatter Gather


In the next step transform the message to json

%dw 2.0
output application/json


Deploy and test the project from soapui, you can see a mule event create with the combination of the results from database calls. Each mule event contains attributes, payload and variables


Now in the next step we will collect the data from both table and combine as a single json object

I have added a new transform component and written a dataweave

%dw 2.0 
output application/json 
(payload[0].payload ++ payload[1].payload) reduce ($ ++ $$)


Deploy and again test the same


Sample application: scattergather sample

Soapui Sample project: ScatterGather-soapui-project.xml


Thank you for taking out time to read the above post. Hope you found it useful. In case of any questions, feel free to comment below. Also, if you are keen on knowing about a specific topic, happy to explore your recommendations as well.
For any latest updates or posts on our website, you can follow us on LinkedIn. Look forward to connecting with you there.

Share this:
Notify of
1 Comment
Newest Most Voted
Inline Feedbacks
View all comments
Md imtiyaz
Md imtiyaz
2 years ago

Good concept