MuleSoft Scatter-Gather Router: Architecture & Error Handling
Parallel execution mechanics, thread pooling, timeout management, and extracting successful routes from partial failures.
If Route 1 succeeds but Route 2 fails in Scatter-Gather, what happens?
🎯 HOW TO ANSWER (SENIOR ARCHITECT SCRIPT)
Scatter-Gather executes all routes in parallel. If any route fails, the router throws a MULE:COMPOSITE_ROUTING error. However, successful routes still finish execution. In the error handler, you can inspect error.errorMessage.payload to access the individual results and errors of each route.
💻 CODE / ARCHITECTURE CONFIGURATION
%dw 2.0
output application/json
---
{
successData: error.errorMessage.payload.failures pluck ($),
errorDetails: error.description
}
Scatter-Gather vs Parallel ForEach: What are the key architectural differences?
🎯 HOW TO ANSWER (SENIOR ARCHITECT SCRIPT)
Scatter-Gather runs distinct, heterogeneous routes in parallel and yields an object containing numbered route keys. Parallel ForEach iterates over a single collection, executing the same flow logic per item in parallel, and yields an array preserving item order.