Interesting question from a class last week: Since splitting is an outbound routing pattern, what should I do if I wish to perform a splitting operation on an inbound route? What if I want to split while receiving messages?
One solution would be to create a new Inbound Router and implement the pattern there. This would certainly be the cleanest way of doing things. (If you do so, don’t forget to upload it to the MuleForge project so that others can use the router too!)
An easier solution would be to concatenate services together.
– Have a single service that receives the inbound message. If there is no router on the inbound and if this is a bridge service, the message is handed over to the outbound router collection.
– Use the appropriate outbound splitter router to split the message. Send all message fragments to a single endpoint, e.g., vm://split.message
– Set up this single endpoint (vm://split.message) as the sole inbound endpoint for a new secondary service.
The secondary service now has received the split message and can handle the individual message fragments individually.