MuleESB / Apache Camel Interview Questions
What is the Exchange in Camel — in-message, out-message, headers, and properties?
The Exchange is the message-passing container that travels through an entire route. When a consumer endpoint receives input, Camel wraps it in an Exchange and passes that object through every Processor. Everything a Processor needs — payload, metadata, and context — is accessed through the Exchange.
- In-message (exchange.getIn()): The current message with body, headers, and attachments. Processors read and write to this.
- Out-message (exchange.getOut()): The reply in InOut exchanges. In Camel 3.x writing to getOut() is discouraged because it creates a fresh Message and silently drops all headers set by prior processors.
- Headers: A Map<String, Object> on the current message. Components auto-populate keys like CamelFileName and JMSMessageID.
- Properties: Exchange-wide key-value pairs that persist across EIP steps like split() or aggregate().
- ExchangePattern: InOnly (fire-and-forget) or InOut (request-reply).
- Exception: Captured via exchange.getException() when a Processor throws.
from("direct:start")
.process(exchange -> {
String body = exchange.getIn().getBody(String.class);
exchange.getIn().setHeader("processedBy", "OrderProcessor");
exchange.setProperty("orderId", "ORD-1234"); // survives split
exchange.getIn().setBody(body.toUpperCase());
});
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...
