Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Camel supports pluggable ErrorHandler strategies to deal with errors processing an Event Driven Consumer. An alternative is to specify the error handling directly in the DSL using the Exception Clause.

For introduction and background material see Error handling in Camel.

Info
titleCamel 2.0 has a new default error handler

In Camel 2.0 onwards there default error handler is changed from Dead Letter Channel to DefaultErrorHandler. This error handler does not support a dead letter queue and will return exceptions back to the caller. This is what you expects when working with regular Java that exceptions will be thrown back to the caller. This error handler supports a limited set of features.

Tip
titleException Clause

Using Error Handler combined with Exception Clause is a very powerful ally. We encourage end-users to use this combination in your error handling strategies. See samples and Exception Clause.

The current implementations Camel provides out of the box are:Some current implementations include

Non transacted

  • DefaultErrorHandler is the default error handler in Camel 2.0 onwards. This error handler does not support a deal letter queue, it will propagate exceptions back to the caller, as if there where no error handler at all. It has a limited set of features.
  • Dead Letter Channel which supports attempting to redeliver the message exchange a number of times before sending it to a dead letter endpoint
  • LoggingErrorHandler for just catching and logging exceptions
  • NoErrorHandler for no error handling

...

  • TransactionErrorHandler is the default error handler in Camel 2.0 onwards for transacted routes. This error handler does not support a deal letter queue, it will propagate exceptions back to the caller, as if there where no error handler at all. It has a limited set of features.
  • Transaction for transactional error handling (Spring based). See the Transactional Client EIP pattern.
Info
titleCamel 2.0 has new default error handler

In Camel 2.0 onwards there default error handler is changed from Dead Letter Channel to DefaultErrorHandler. This error handler does not support a dead letter queue and will return exceptions back to the caller. This is what you expects when working with regular Java that exceptions will be thrown back to the caller. This error handler supports a limited set of features.

Tip
titleIntroduction

For introduction and background material see Error handling in Camel.

...

titleException Clause

...

These error handlers can be applied in the DSL to an entire set of rules or a specific routing rule as we show in the next examples. Error handling rules are inherited on each routing rule within a single RouteBuilder

Note
titleTransaction in Camel 1.x

If the route is transactional then the Dead Letter Channel is disabled. The exchange.isTransacted() is used to determine if an Exchange is transacted or not.
So if you are using transacted routes then you should configure the TransactionErrorHandler instread of DeadLetterChannel. See Transactional Client for further details and samples.

These error handlers can be applied in the DSL to an entire set of rules or a specific routing rule as we show in the next examples. Error handling rules are inherited on each routing rule within a single RouteBuilder

Short Summary of the provided Error Handlers

...

The TransactionErrorHandler is the new default error handler in Camel 2.0 for transacted routes. It only supports a limited set of features such as catching exception and using the Exception Clause. It does not support redelivery, delays or the likes. It will propagate exceptions back to the original caller. It does not have any dead letter queue.

Tip
[TransactionErrorHandler] is default for transacted routes
[TransactionErrorHandler] is default for transacted routes

If you have marked a route as transacted using the transacted DSL then Camel will automatic use a TransactedErrorHandler. It will try to lookup the global/per route configured error handler and use it if its a TransactionErrorHandlerBuilder instance. If not Camel will automatic create a temporary TransactionErrorHandler that overrules the default error handler. This is convention over configuration.

Scopes

The error handler is scoped as either

...