MuleESB / Apache Camel Interview Questions
How does the Dead Letter Channel work and how do you configure error handling in Camel?
The Dead Letter Channel (DLC) is a default error handler that retries failed exchanges a configurable number of times and, on exhaustion, routes the Exchange to a designated dead-letter endpoint. It prevents message loss when downstream systems are temporarily unavailable.
// Configure Dead Letter Channel on the RouteBuilder:
public class MyRoutes extends RouteBuilder {
@Override
public void configure() {
errorHandler(deadLetterChannel("jms:queue:DLQ")
.maximumRedeliveries(3)
.redeliveryDelay(1000) // 1s initial delay
.backOffMultiplier(2.0) // doubles: 1s, 2s, 4s
.retryAttemptedLogLevel(LoggingLevel.WARN)
.logExhausted(true)
.useOriginalMessage()); // send original msg, not transformed
from("jms:queue:orders")
.to("http://payment-service/pay");
}
}When all retries are exhausted, Camel adds an exception header (CamelExceptionCaught) to the Exchange before routing to the DLQ. useOriginalMessage() ensures the pristine inbound message reaches the DLQ, not a partially transformed version. The DLC can be scoped at route level (inside configure()) or globally (in a parent class). For per-exception handling, combine with onException().
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...
