You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Hilde <hi...@yahoo.de> on 2012/07/11 17:22:24 UTC

Basic knowledge: onException

Hello fellows!

Can somebody explain me why the exception handling in camel can be
non-handeld? Furthermore that is the default if you are using 

/*onExchange(Exception.class).end()*/

In my opinion it makes no sense when you cannot handle the exception. And
what impacts has the
construct above in a route scope anyway? It is not revealed to me what makes
the difference in omit or apply it - the exception is thrown anyway.

Cheers
Hilde



--
View this message in context: http://camel.465427.n5.nabble.com/Basic-knowledge-onException-tp5715861.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Basic knowledge: onException

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Jul 12, 2012 at 9:45 AM, Hilde <hi...@yahoo.de> wrote:
> Hello Claus!
>
> Thank you for your efforts in explaining me.
>
> If I get you right it means that a non handeld exception propagates the
> exception back
> to the caller whereas a route with no exception handling is lost or it is
> propagated to
> the default error handler?
>

Yes if you have onException then that kicks in, instead of the error handler.
So the onException is for fine grained error handler, based on the
exception type.

Where as error handler is coarse grained to deal with any other kind
of exceptions, and as a fallback etc.

So only one of them will kick-in and react upon the exception. Either
onException or the error handler.


> Hilde
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Basic-knowledge-onException-tp5715861p5715927.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: Basic knowledge: onException

Posted by Hilde <hi...@yahoo.de>.
Hello Claus!

Thank you for your efforts in explaining me.

If I get you right it means that a non handeld exception propagates the
exception back
to the caller whereas a route with no exception handling is lost or it is
propagated to
the default error handler?

Hilde



--
View this message in context: http://camel.465427.n5.nabble.com/Basic-knowledge-onException-tp5715861p5715927.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Basic knowledge: onException

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Jul 12, 2012 at 9:14 AM, Hilde <hi...@yahoo.de> wrote:
> Hello Claus!
>
> I have read chapter 5 more and more and more but the sense of a non handled
> exception
> I have not figured out. In addition in chapter 5 there is no sentence about
> the sense of a
> non handled exception.
>

Yes often people want to do a onException with handled(true). But
there are use-cases where you want the exception to not be handled,
and propagate back to the caller, and thus handled(false).
Handled(false) was the default behavior in Camel 1.x and therefore
kept as is in 2.x as well.

For example you can use this to do a logging saying that the exception
occurred but you could not handle it
for example

onException(IOException.class).maximumRedeliveries(3)
   .log("All redeliveries failed as well. We cannot process this
message. Exception not handled, and propagated back to the caller)
.end()



> Cheers
> Hilde
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Basic-knowledge-onException-tp5715861p5715922.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: Basic knowledge: onException

Posted by Hilde <hi...@yahoo.de>.
Hello Claus!

I have read chapter 5 more and more and more but the sense of a non handled
exception 
I have not figured out. In addition in chapter 5 there is no sentence about
the sense of a 
non handled exception.

Cheers
Hilde

--
View this message in context: http://camel.465427.n5.nabble.com/Basic-knowledge-onException-tp5715861p5715922.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Basic knowledge: onException

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Jul 11, 2012 at 5:22 PM, Hilde <hi...@yahoo.de> wrote:
> Hello fellows!
>
> Can somebody explain me why the exception handling in camel can be
> non-handeld? Furthermore that is the default if you are using
>

People have different use-case how to deal with that, and thus they
have a choice.

> /*onExchange(Exception.class).end()*/
>

Yes this does not make sense to do. In Camel 3.0 we will improve the
DSL to be more strict and invalidate such kind of configurations.


> In my opinion it makes no sense when you cannot handle the exception. And
> what impacts has the
> construct above in a route scope anyway? It is not revealed to me what makes
> the difference in omit or apply it - the exception is thrown anyway.
>

Error handling is hard, so take your time to read the docs, and other
links / blog posts etc.
http://camel.apache.org/error-handling-in-camel.html
http://www.consulting-notes.com/2010/08/camel-exception-handling-overview.html

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

> Cheers
> Hilde
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Basic-knowledge-onException-tp5715861.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