ENTERPRISE INTEGRATION PATTERNS IN MULE
Patterns, patterns everywhere
One of the most influential books on integration is Enterprise Integration Patterns by Gregor Hohpe and Bobby Woolf. Many of the integration patterns and functionality you see in integration middleware today stands on the shoulders of these patterns. I’ll be launching a series of posts that demonstrate the use of these patterns implemented by MuleSoft. Starting off from smaller patterns and building upon that, starting off with the Splitter.
The Splitter
“How can we process a message if it contains multiple elements, each of which may have to be processed in a different way?”
Use a Splitter to break out the composite message into a series of individual messages, each containing data related to one item.

Let’s take the example of a retailer’s shipment. A shipment typically contains a shipment ID and a manifest of all the packages within it.
I want to split the shipment into multiple packages, each one self contained to represent a single package and enable stateless processing. This may mean taking some common elements from the shipment itself, such as the carrier name and shipment ID, and including it in each package message.
Once these packages have been processed, it might be necessary to recompose them into a single message. A correlation ID (such as the shipment ID) may be suitable to herd these packages back into a whole.
We don’t include any business logic in the splitting of the shipment that involves complex routing logic. Instead we treat it as if the messages are subject to series of downstream pipes and filters that breaks out the processing to composable services.
The MuleSoft Way
In Mule 3 there was a component called “splitter”. As crazy at is seems, this implemented the Splitter pattern (who knew!?) and would insert a correlation ID into each message. Mule 4 has simplified splitting by just leveraging the for-each scope. You can perform the split based on a dataweave expression that yields a collection to the for-each block. The correlation ID is automatically provided to each item processed. OK so it's not called a splitter any more, but if it looks like a Mule, and walks like a Mule 🙂