Splitting a List
I’ve talked about the List-Message-Splitter router before but have not had time to document a simple example of it yet.
Consider a situation where you have a component that produces a list of items, or perhaps a service which receives a list over an endpoint. Either way, you need to split this list into a series of independent messages – one per item on the list.
The list-message-splitter router is an outbound routing pattern that does precisely this. It will unpack a list and will send the individual items along one or more endpoints. Furthermore, you can use filters on the endpoints to make sure that different items get sent to different endpoints.
Take a look:
<outbound> <list-message-splitter-router> <outbound-endpoint ref="mule.queue"> <payload-type-filter expectedType="com.ricston.tests. ListGenerator"/> </outbound-endpoint> <outbound-endpoint ref="object.queue"> <payload-type-filter expectedType="java.lang.Object"/> </outbound-endpoint> </list-message-splitter-router> </outbound>
Here you can see that the router is configured using multiple endpoints. Each endpoint has a filter on it so that:
– If an item on the list matches the first payload filter (“Is this item a ListGenerator item?”), we will route it on to the endpoint called mule.queue
– If an item on the list matches the second payload filter (“Is this item a generic object?”) we will route it on to the endpoint called object.queue
I can set up any number of endpoints, of course, or I could just have one single endpoint and let the router send all the items on to that one.

If you enjoyed this post, make sure you subscribe to my RSS feed!
Tags: filter, list-message-splitter, Pattern, payload-type-filter