-
1. Re: Error-Handling and Abort
davsclaus Apr 30, 2010 4:53 AM (in response to t0m.guenter)Error handling is generally hard to do properly.
Anyway you can read about error handling in Camel from here
http://camel.apache.org/error-handling-in-camel.html
There are links to further wiki pages with more details.
However the wiki pages may be understand as its more a reference and some insights here and there.
The Camel in Action book has devoted chapter 5 to error handling in Camel and introduces it from the beginning so you will understand the concepts and principle of error handling in Camel
You generally use error handler and/or onException to handle errors in a general way. Those can be scoped at either context (like global) or route level (only for this route), with fallback to context level.
The try .. catch is more like a think to help people to mirror what they would do in regular Java with its try .. catch for error handling. It has its limits as though.
-
2. Re: Error-Handling and Abort
t0m.guenter May 7, 2010 1:50 AM (in response to davsclaus)Hi,
thanks for your answer. The strategy I currently use is the following:
Abstract Processors and Producers (my routes only use own producers) catch any exception in the process() method and write it into a dedicated header field. Furthermore they check whether a previous step has encountered any problems. In case it has, then nothing will be done in this step.
At the end of the route is a result handler, which checks if the exception field contains the exception and does the general exception handling (writing application exceptions into the response for the client and logging system exceptions). An additional route error handler catches any not handled exception and sends the whole message to a dead letter queue.
In my case, with all processors and producers written by my own, this works fairely good.
route (simplified):
errorHandler(deadLetterChannel(dlqUri))
from(sourceUri)
to(validator1)
to(validator2)
to(processor1)
to(endpoint1)
to(resultHandler)Regards,
Tom