MuleESB / Apache Camel Interview Questions
What are the error handling strategies in Camel (DefaultErrorHandler, DeadLetterChannel, TransactionErrorHandler)?
Camel provides three built-in error handler implementations, configurable per-route via errorHandler(...):
| Handler | Retries | Use case |
|---|---|---|
| DefaultErrorHandler | Configurable (default 0) | Non-transactional routes that log failures. |
| DeadLetterChannel | Configurable (default 0) | Routes needing guaranteed delivery to a DLQ after retries exhausted. |
| TransactionErrorHandler | Driven by transaction manager | JMS/JDBC transactional routes requiring rollback on failure. |
| NoErrorHandler | None | Testing or scenarios where all error handling is done manually. |
// Default (no-DLQ): log on failure
errorHandler(defaultErrorHandler()
.maximumRedeliveries(2)
.redeliveryDelay(500));
// Dead Letter Channel
errorHandler(deadLetterChannel("jms:queue:DLQ")
.maximumRedeliveries(3)
.backOffMultiplier(2.0)
.useOriginalMessage());
// Transactional error handler
errorHandler(transactionErrorHandler(transactionManager)
.maximumRedeliveries(3)
.redeliveryDelay(1000));Error handlers can be scoped globally (in the parent RouteBuilder configure() or in a shared class) or per-route (placed at the start of a specific configure() method). Global scope applies to all routes defined in that builder. For per-exception handling, use onException() on top of any error handler to add targeted retry/routing logic for specific exception types.
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...
