You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by dgallagher <da...@gmail.com> on 2012/06/26 23:18:39 UTC

Camel - error handling

Hi

from reading through camel, there seems like many ways to perform different
operations.
I have a specific question around error handling and what the general
consensus
>From what I can see, there is the dead letter channel, try, catch, finally,
global exceptions etc

>From an application standpoint, can people recommend best practices for what
type of exception handling to perform for individual routes

--
View this message in context: http://camel.465427.n5.nabble.com/Camel-error-handling-tp5715132.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel - error handling

Posted by Ashwin Karpe <ak...@fusesource.com>.
Hi,

The exception handlers are meant to be used the same way as if you were
writing code. It is not possible to offer explicit best practices since
every use case is different. You would need to be explicit about your routes
or use case along with what you are trying to get accomplished.

In general, however, you can have try-catch-finally or on-exception handlers
for route specific exception handling. And global/scoped exception handlers
for catch-all exceptions. Exception handlers are scoped and can cascade to
global handlers if not handled locally.

Dead letter or Transacted exception handlers are meant to offer specific
kinds of treatment/handling to exceptions being thrown (i.e move to a DLQ or
replace back on the input queue for a retry etc). 
 
Hope this helps.

Cheers,

Ashwin...

-----
---------------------------------------------------------
Ashwin Karpe
Apache Camel Committer & Sr Principal Consultant
FUSESource (a Progress Software Corporation subsidiary)
http://fusesource.com 

Blog: http://opensourceknowledge.blogspot.com 
---------------------------------------------------------
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-error-handling-tp5715132p5715133.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel - error handling

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Jun 27, 2012 at 8:17 PM, dgallagher <da...@gmail.com> wrote:
> Thanks Guys
>
> If I use the global exception handling (e.g. onException) with Java DSL, do
> i need to define a separate route that contains the onException code so that
> every route in the context will pick it up?
>

Yes with the Java DSL and if you use 2+ RouteBuilder classes, is that
if want to share
error handlers between them, you would need to create a base class
extending RouteBuilder. And
then let your route builders extend your base class. And in your base
class, do the global error handling.
And then remember to call super.configure().



> Thanks
> Damien
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-error-handling-tp5715132p5715177.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Camel - error handling

Posted by Christian Müller <ch...@gmail.com>.
No, you can also do the following:
onException(OrderFailedException.class)
  .handled(true)
  .bean(ErrorHandlerBean.class, "orderFailed")
  ...
  .to("mock:error");

Best,
Christian

On Wed, Jun 27, 2012 at 8:17 PM, dgallagher <da...@gmail.com>wrote:

> Thanks Guys
>
> If I use the global exception handling (e.g. onException) with Java DSL, do
> i need to define a separate route that contains the onException code so
> that
> every route in the context will pick it up?
>
> Thanks
> Damien
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-error-handling-tp5715132p5715177.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Camel - error handling

Posted by dgallagher <da...@gmail.com>.
Thanks Guys

If I use the global exception handling (e.g. onException) with Java DSL, do
i need to define a separate route that contains the onException code so that
every route in the context will pick it up?

Thanks
Damien

--
View this message in context: http://camel.465427.n5.nabble.com/Camel-error-handling-tp5715132p5715177.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel - error handling

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Besides the docs at Apache there is a few blog posts, such as
http://www.consulting-notes.com/2010/08/camel-exception-handling-overview.html

And if you have a copy of the Camel in Action book, then the entire
chapter 5 is devoted to error handling.


On Tue, Jun 26, 2012 at 11:18 PM, dgallagher <da...@gmail.com> wrote:
> Hi
>
> from reading through camel, there seems like many ways to perform different
> operations.
> I have a specific question around error handling and what the general
> consensus
> From what I can see, there is the dead letter channel, try, catch, finally,
> global exceptions etc
>
> From an application standpoint, can people recommend best practices for what
> type of exception handling to perform for individual routes
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-error-handling-tp5715132.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen