Saturday, 2 June 2018

Splitter and Aggregator

The Splitter Flow Control splits a message into separate fragments, then sends these fragments one at a time to the next message processor in the flow. Segments are identified based on an expression parameter, usually written in Mule Expression Language (MEL), but other formats can be employed also. You can then use a Collection Aggregator Flow Control to reassemble the parts of the original message. You can also include a Resequencer Flow Control to put the parts back into the original sequence in case they are shuffled out of order.

Let’s take a scenario to understand the problem, there is process which calculates payroll of all employees. To design this problem in the following steps
  •       Initial process queries the database and fetch the employee records
  •        There is a payroll process defined, it takes the employee record as input and calculates the salary for an employee.
  •        Employee collection is retrieved from the Step-1, Iterate the employee collection and pass an employee to Step-2 to calculate the salary for an employee
  •       If salary calculatio n for an employee takes 1 sec. salary calculation of 100 employee takes around 100 seconds.
  •     To increase the performance to above design we engage the splitter-aggregator component instead of iterating the employee collection get from Step-1

Splitter splits the employee collection in to parts of employee records, each part consists of employee record, processing of salary calculation of each employee handled by a separate thread, salary calculation of all employees happens concurrently by each thread. So now whole payroll calculation happens in I sec.

In the above example we got 5 records from the database, if we are not using splitter to split the resultset, we need to iterate the collection and process each record sequentially. In this scenario usage of Splitter improves the performance of application.

Aggregating the Payload

When the splitter splits a message, it adds three new outbound variables into each of the output fragments. These three variables are later used by the Aggregator to reassemble 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 entire group (all output fragments of the same original message share the same value).
Create table in mysql Database

CREATE TABLE `employee` (
  `id` varchar(20) NOT NULL DEFAULT '',
  `EMP_NAME` varchar(45) DEFAULT NULL,
  `EMP_DESIG` varchar(45) DEFAULT NULL,
  `LOCATION` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`id`)

Insert 2 sample records using below Insert statement:
INSERT INTO `mule_support`.`employee`
(<{id: }>,
<{EMP_NAME: }>,
<{EMP_DESIG: }>,
<{SALARY: }>,

<{LOCATION: }>);

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:db="" xmlns:http="" xmlns="" xmlns:doc=""
    <http:listener-config name="HTTP_Listener_Configuration" host="${}" port="${http.port}" doc:name="HTTP Listener Configuration"/>
    <db:mysql-config name="MySQL_Configuration" host="${}" port="${db.port}" user="${db.username}" database="${db.schema}" doc:name="MySQL Configuration" password="${db.password}"/>
    <flow name="splitter_demoFlow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
        <db:select config-ref="MySQL_Configuration" doc:name="Database">
            <db:parameterized-query><![CDATA[select * from  employee]]></db:parameterized-query>
        <collection-splitter doc:name="Collection Splitter">
            <expression-message-info-mapping messageIdExpression="#[]" correlationIdExpression="#[message.correlationId]"/>
        <logger message="Salary of employee is #[payload.SALARY]" level="INFO" doc:name="Logger"/>
        <collection-aggregator failOnTimeout="true" doc:name="Collection Aggregator"/>
        <logger message="after splitter------------------" level="INFO" doc:name="Logger"/>
        <byte-array-to-string-transformer doc:name="Byte Array to String"/>

Complete source code of application can download from

Testing application with POSTMan



  1. Valuable post useful for everyone.Keep on sharing.
    Mulesoft Online Training

  2. Hi there! Nice post! Please tell us when I will see a follow up! compact tractors

  3. This is a truly good site post. Not too many people would actually, the way you just did. I am really impressed that there is so much information about this subject that have been uncovered and you’ve done your best, with so much class. If wanted to know more about green smoke reviews, than by all means come in and check our stuff. easy taxi schiphol

  4. Great post, you have pointed out some fantastic points , I likewise think this s a very wonderful website. 안전놀이터

  5. Great content material and great layout. Your website deserves all of the positive feedback it’s been getting. 안전놀이터

  6. Someone Sometimes with visits your blog regularly and recommended it in my experience to read as well. The way of writing is excellent and also the content is top-notch. Thanks for that insight you provide the readers! 먹튀검증

  7. Hi there! Nice post! Please tell us when I will see a follow up! 안전놀이터

  8. What is an outstanding post! “I’ll be back” (to read more of your content). Thanks for the nudge! 무료릴게임

  9. I’ve read some good stuff here. Definitely worth bookmarking for revisiting. I surprise how much effort you put to create such a great informative website. 먹튀검증커뮤니티

  10. Wonderful blog! I found it while surfing around on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Appreciate it. pii-email

  11. Keep up the good work , I read few posts on this web site and I conceive that your blog is very interesting and has sets of fantastic information. 토토커뮤니티

  12. Good website! I truly love how it is easy on my eyes it is. I am wondering how I might be notified whenever a new post has been made. I have subscribed to your RSS which may do the trick? Have a great day! สล็อต

  13. Good website! I truly love how it is easy on my eyes it is. I am wondering how I might be notified whenever a new post has been made. I have subscribed to your RSS which may do the trick? Have a great day! 토토사이트

  14. Nice post. I was checking constantly this blog and I’m impressed! Extremely useful info specially the last part I care for such information a lot. I was seeking this certain info for a long time. Thank you and good luck. 팔팔카

  15. This type of message always inspiring and I prefer to read quality content, so happy to find good place to many here in the post, the writing is just great, thanks for the post. 안전놀이터

  16. It’s appropriate time to make some plans for the future and it is time to be happy. I have read this post and if I could I wish to suggest you few interesting things or advice. Perhaps you could write next articles referring to this article. I desire to read even more things about it! 파워볼게임

  17. Yes i am totally agreed with this article and i just want say that this article is very nice and very informative article.I will make sure to be reading your blog more. You made a good point but I can't help but wonder, what about the other side? !!!!!!Thanks 대전건마

  18. Very interesting information, worth recommending. However, I recommend this:

  19. I am interested in such topics so I will address page where it is cool described.

  20. RSJ is at the top of our game when it comes to tax-minimization strategies for asset growth, protection and transfer. We have always known that something was missing from traditional estate planning for high-net-worth families. Family Wealth Services

  21. Acknowledges for paper such a beneficial composition, I stumbled beside your blog besides decipher a limited announce. I want your technique of inscription...

  22. You bear through a particular opening. I mental consistency clearly quarry it correspondingly truly propose to my buddys. I'm held they explanation be benefitted by this scene.

  23. I think this is an informative post and it is very beneficial and knowledgeable. Therefore, I would like to thank you for the endeavors that you have made in writing this article. All the content is absolutely well-researched. Thanks... 현금바둑이

  24. Wonderful blog! Do you have any tips and hints for aspiring writers? Because I’m going to start my website soon, but I’m a little lost on everything. Many thanks! 온라인바둑이

  25. Your blogs further more each else volume is so entertaining further serviceable It appoints me befall retreat encore. I will instantly grab your rss feed to stay informed of any updates. Slot

  26. I am always searching online for storys that can accommodate me. There is obviously a multiple to understand about this. I feel you made few salubrious points in Attributes moreover. Detain busy, awesome career! เทคนิคบาคาร่า

  27. This is very appealing, however , it is very important that will mouse click on the connection: หนังโป๊ฟรี

  28. Cool you write, the information is very good and interesting, I'll give you a link to my site. หนังโป๊ฟรี

  29. It is fine, nonetheless evaluate the information and facts around this correct. หนังโป๊ฟรี

  30. This is very interesting, but it is necessary to click on this link: หนังโป๊ฟรี

  31. I personally use them exclusively high-quality elements : you will notice these folks during: ดูหนังโป๊ออนไลน์

  32. Very interesting information, worth recommending. However, I recommend this: sagame ทดลอง

  33. Acknowledges for paper such a beneficial composition, I stumbled beside your blog besides decipher a limited announce. I want your technique of inscription... pg slot ทางเข้า

  34. For this web site, you will see our account, remember to go through this info. PGSLOT AUTO

  35. I invite you to the page where you can read with interesting information on similar topics. คาสิโนออนไลน์

  36. During this website, you will see this shape, i highly recommend you learn this review. สล็อต xo เครดิตฟรี

  37. Acknowledges for paper such a beneficial composition, I stumbled beside your blog besides decipher a limited announce. I want your technique of inscription... joker mobile

  38. Mmm.. estimable to be here in your report or notify, whatever, I repute I should moreover process strong for my have website want I play some salubrious further updated busy in your location. pgslot download

  39. You ought to basically fantastic not to mention solid advice, which means notice: คาสิโนออนไลน์ สล็อต

  40. I also wrote an article on a similar subject will find it at write what you think. เค้าไพ่บาคาร่า

  41. I would recommend my profile is important to me, I invite you to discuss this topic. sexybaccarat

  42. So it is interesting and very good written and see what they think about other people. slot gaming

  43. For many people this is the best solution here see how to do it. เทคนิคบาคาร่า

  44. This is the type of information I’ve long been trying to find. Thank you for writing this information. 먹튀검증

  45. Good Information, I've seen on the internet, need something like this more from more people posted. Keep posts like this. make me understand about situs slot pragmatic , link login joker123 , slot joker123 , situs togel online, situs pkv games

  46. hideouttv
    AdsRePay is an online rewards and cashback site. It's completely FREE to register and use, and best of all, you can start earning right away. Complete simple offers from our partners, earn points and then simply redeem your points anytime for instant Paypal and Amazon Gift Cards


How to quick start your Mulesoft professional journey

Mulesoft is leading and Fast growing Application integration framework in the industry. Do you want to start professional journey in Mulesof...