Scatter Gather in Mule 4
1.The Scatter-Gather component is a routing event processor that processes a Mule event through different parallel processing routes that contain different event processors.
2. 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.
3.The Scatter-Gather component executes each route in parallel, not sequentially. Parallel execution of routes can greatly increase the efficiency of your Mule application and may provide more information than sequential processing.
4.The Scatter-Gather component works with repeatable streams. It does not process nonrepeatable streams, which can be read only once before they are lost. By default, all streams are repeatable in Mule unless a component’s streaming strategy is configured to be nonrepeatable.
5. Use case : Here, the following operation is to be performed add and sub two numbers using scatter gather component. In this If all flows are success then it will be execute successfully.
6. In this flow my condition is addition and subtraction of two numbers.
i.e. (add: 20 + 10) and (sub: 20–10).
7. The response for my flow for scatter gather is as mention below.
8. If any one flow not success in the scatter gather then it will be throws error and it is called “Composite error”.
9. Use case: In this flow I have scatter gather and 3 flow references for add, sub and div two no and I am also taken error handling in my flow as I am passing the the wrong value and it will be throw error to my flow and I am using “On-Error Continue” components it will be go to error handling.
10. In this flow I am passing the values for (div: 20/0), Now it will be throws error as I am passing the value 20/0 and its throws errors and it is called as “Composite Routing”
Conclusion: In Scatter-Gather If any one of the event processor fails then it will throw an error and it is called as “Composite Error”