splitter and collection aggregator with mulesoft
TRANSCRIPT
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.
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
•.
SPLITTING THE MESSAGE PAYLOAD
Place the Splitter component in Message processor region after HTTP Listener.
•.
SPLITTING THE MESSAGE PAYLOAD
Place the DOM to XML transformation after Splitter, 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.
•.
TESTING THE APPLICATION
You can use Postman to post the message. The listening URL will be
http://localhost:8081/splitter.
Sample input message:
•.
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.
•.
TESTING THE APPLICATION
Now, you can verify the file location and check if the message is properly split into five
different files.
•.
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).
•.
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.
•.
AGGREGATING MESSAGE PAYLOAD
In continuation with above example, place Collection Aggregator after Splitter.
•.
AGGREGATING MESSAGE PAYLOAD
Collection Aggregator will aggregate all the split messages into a single payload.
•.