2. Splitter and Collection Aggregator
Splitter is used to split Mule messages into separate fragments. Each fragment is
then sent one at a time to the next processor in the flow. Segments are identified
by expression parameters and are generally written in MEL (Mule Expression
Language).You can then use a Collection Aggregator Flow Control to reassemble
the parts of the original message.
3. Splitting the Message Payload
Place the HTTP listener into the canvas and click to open the Properties console.
Click the green + and configure as follows:
•HOST: LOCALHOST.
•PORT: 8081.
•METHOD: POST.
•PATH: SLITTER
•.
4. Splitting the Message Payload
Place the Splitter component in Message processor region after HTTP Listener.
•.
6. Splitting the Message Payload
Place the DOM to XML transformation afterSplitter, as it will convert the split
message object into XML.
Finally, place the file connector at the end of message processor to save all split
messages.
•.
7. Testing the application
You can use Postman to post the message. The listening URL will be
http://localhost:8081/splitter.
Sample input message:
•.
8. Testing the application
The above sample input message will be split into five messages and will be
saved to file location as five different files.
•.
9. Testing the application
Now, you can verify the file location and check if the message is properly split
into five different files.
•.
10. Aggregating message payload
Now, you can verify the file location and check if the message is properly split
into five different files.
When Mule splits the message, it adds three new outbound variables into
each of the output fragments. This you can use later when aggregating the
message.
•MULE_CORRELATION_GROUP_SIZE: NUMBER OF FRAGMENTS INTO WHICH THE
ORIGINAL MESSAGE WAS SPLIT.
•MULE_CORRELATION_SEQUENCE: POSITION OF A FRAGMENT WITHIN THE
GROUP.
• MULE_CORRELATION_ID: SINGLE ID FOR THE ENTIRE GROUP (ALL OUTPUT
FRAGMENTS OF THE SAME ORIGINAL MESSAGE SHARE THE SAME
VALUE).
•.
12. Aggregating message payload
These three variables play an important role while aggregating the message, as
they know what group to put it into and what the size of group is. Once all
the split messages are received, it passes any split messages into one aggregated
group.
•.