Resequencer in Mule

Resequencer in Mule

Resequencer holds a group of message and re sequences them using each message's correlation sequence property.

The Resequencer waits for all of the messages in the group to arrive (keeping track of MULE_CORRELATION_ID and MULE_CORRELATION_GROUP_SIZE) and then reorder them according to their MULE_CORRELATION_SEQUENCE index.

The Resequencer outputs three distinct messages, so the Aggregator is still needed to merge them into one.

With the Resequencer in place, messages now reach the aggregator in the correct order and are assembled accordingly.To really take advantage of splitting the message, you should deploy your app to a cluster of servers. By following the steps below, you can simulate the random delays of a cluster of servers.

flow of resequencer

Splitter and Collection aggregator we have discussed in other tutorials too.So here i am going to show only Resequencer configuration.

URL : http://localhost:8085/api/resequencer
Method : POST

Input :

<Employees> <Employee> <FirstName>Himanshu</FirstName> <LastName>Pal</LastName> <Salary>120000</Salary> </Employee> <Employee> <FirstName>Sonam</FirstName> <LastName>Sharma</LastName> <Salary>200000</Salary> </Employee> <Employee> <FirstName>Piyush</FirstName> <LastName>Joshi</LastName> <Salary>300000</Salary> </Employee> <Employee> <FirstName>Vinod</FirstName> <LastName>Shukla</LastName> <Salary>800000</Salary> </Employee> <Employee> <FirstName>Kunal</FirstName> <LastName>Verma</LastName> <Salary>500000</Salary> </Employee> </Employees>

Output :

XML project code :

<?xml version="1.0" encoding="UTF-8"?> <mule xmlns:file="" xmlns:mulexml="" xmlns:http="" xmlns="" xmlns:doc="" xmlns:spring="" xmlns:xsi="" xsi:schemaLocation=""> <http:listener-config name="HTTP_Listener_Configuration" host="" port="8085" basePath="/api" doc:name="HTTP Listener Configuration"/> <file:connector name="File" writeToDirectory="src/main/resources/splitted" autoDelete="true" streaming="true" validateConnections="true" doc:name="File"/> <flow name="test_resequencerFlow"> <http:listener config-ref="HTTP_Listener_Configuration" path="/resequencer" doc:name="HTTP"/> <splitter expression="#[xpath('//Employee')]" doc:name="Splitter"/> <mulexml:dom-to-xml-transformer doc:name="DOM to XML"/> <file:outbound-endpoint path="src/main/resources/splitted" connector-ref="File" responseTimeout="10000" doc:name="File"/> <resequencer failOnTimeout="true" doc:name="Resequencer"> </resequencer> <collection-aggregator failOnTimeout="true" doc:name="Collection Aggregator"/> <mulexml:dom-to-xml-transformer doc:name="DOM to XML"/> </flow> </mule>