MuleESB / Apache Camel Interview Questions
How does the Splitter EIP work and when would you use it?
The Splitter breaks a single message into multiple sub-messages, processes each independently, and optionally aggregates the results. It is used when a single inbound message contains a collection of items (a CSV line batch, a JSON array, an XML node list) that must be processed individually.
// Split a CSV line batch into individual records:
from("file:/in?noop=true")
.unmarshal().csv()
.split(body()) // splits List into individual rows
.parallelProcessing() // optional: process sub-messages in parallel
.streaming() // optional: do not buffer the whole list
.to("jms:queue:order-items")
.end(); // end of splitter sub-route
// Split XML using XPath:
from("direct:xmlOrders")
.split(xpath("//order"))
.to("direct:processOrder");Each sub-message gets a copy of the original headers plus Camel-generated metadata: CamelSplitIndex (0-based position), CamelSplitSize (total count), and CamelSplitComplete (true on last item). The sub-route between split() and end() is a full processing pipeline. Use streaming() for large collections to avoid loading everything into memory.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
