Message Chunk Splitter & Message Chunk Aggregator in Mule





Message Chunk Splitter & Message Chunk Aggregator in Mule





Message Chunk Splitter splits message in form of chunks or fixed size message.We need to define size of message in configuration settings of Message Chunk Splitter.

Message Chunk Aggregator aggregates the splitted message in original form.


The Aggregators module contains different types of aggregators capable of storing values and releasing them all together based on the configuration specified. An Aggregator is a component used to collect those values until a condition is met, then execute a processor’s chain with the list of aggregated elements as the payload.

An Aggregator is a pass-through router, meaning that the same message that is processed by the aggregator is going to be processed by the components that follow it. The only modifications are the addition of some message attributes that provide information about the aggregation.

The basic aggregator configuration consists of the definition of the value that will be aggregated (extracted from the message through an expression evaluation), a condition that defines when the aggregation is considered complete, and a processor chain that will be executed once that condition is met.

flow of Message Chunk Splitter & Message Chunk Aggregator





Message Chunk Splitter configuration :



splitted files are located in a folder named splitted in src/main/resources



Message chunk aggregator configuration : As i said, nothing is required to configure inside it, so leave as it is.




URL : http://localhost:8085/api/chunksplitter
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="http://www.mulesoft.org/schema/mule/file" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:wmq="http://www.mulesoft.org/schema/mule/ee/wmq" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd http://www.mulesoft.org/schema/mule/ee/wmq http://www.mulesoft.org/schema/mule/ee/wmq/current/mule-wmq-ee.xsd http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd"> <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8085" basePath="/api" doc:name="HTTP Listener Configuration"/> <file:connector name="File" writeToDirectory="./src/main/resources/splitter" autoDelete="false" streaming="false" validateConnections="true" doc:name="File"/> <flow name="test_messagechunksplitterFlow"> <http:listener config-ref="HTTP_Listener_Configuration" path="/chunksplitter" doc:name="HTTP"/> <message-chunk-splitter messageSize="256" doc:name="Message Chunk Splitter"/> <file:outbound-endpoint path="./src/main/resources/splitter" connector-ref="File" responseTimeout="10000" mimeType="application/xml" doc:name="File"/> <message-chunk-aggregator failOnTimeout="true" doc:name="Message Chunk Aggregator"/> <set-payload value="#[payload]" doc:name="Set Payload"/> </flow> </mule>



© 2020 goformule.com

Share on :

Mule 4:

XML to JSON in mule 4 Web service consumer VM Validation in Mule 4 Until Successful
Sub flow Set Variable & Remove Variable Set Transaction ID Scatter Gather Round Robin
Consume Restful Service CRUD in Mule 4 Parse Template Object to JSON Load Static Resource
JSON to XML Invoke Idempotent Filter ForEach Flat file to JSON
Fixwidth to JSON First Successful File Execute Error Handling
Email Dynamic Evaluate Custom Business Event CSV to JSON Copybook to JSON
Choice Router Async RabbitMQ


Mule 3:


Database Connector Async CXF Attachement XSLT
Mongo DB Cache scope Custom Business Event Gzip Compress Expression
SMTP For Each Expression Javascript Filter Reference
Salesforce Message Enricher Groovy Parse Template Idempotent
VM Poll Invoke Ruby Message
Webservice consumer Python Transformer reference Message Property Not
Collection Aggregator First Sucessful Catch Exception Strategy Reference Exception Strategy Or
Choice Message Chunk Aggregator Choice Exception Strategy Global Exception Strategy Schema Validation
Custom Aggregator Scatter Gather Custom Exception Strategy Batch Processing MEL
M Unit RAML Map Operator API Mocking Dataweave