You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by jackkirsten <jk...@hotmail.com> on 2011/12/11 22:16:37 UTC

Camel OnException handling

Hi, I have the following OnException blocks for both generic checked
exception and runtime exceptions.  When I purposely throw the runtime
exception such as (NullPointerException) from the process method, only
Exception.class block is executed and NOT the Runtime.Exception block.  Why
is it doing this?  How do I fix this so that the appropriate exceptions go
to the correct onException blocks?

from("seda://OrderID")
    .routeId("OrderProcessorRoute")
*    .onException(RuntimeException.class).maximumRedeliveries(0)
        .handled(true)
	.log("***** Some Runtime Exceptions Occured. *****")
        .inOut("direct:exceptionHandling")
        .end()
    .onException(Exception.class).maximumRedeliveries(5)
        .redeliveryDelay(6000)
        .handled(true)
	.log("***** Some Checked Exceptions Occured. *****")
       .inOut("direct:exceptionHandling")
       .end()
*
        .transacted("TestTXPolicy")
        	.inOut("bean:OrderProcessor?method=processStep1")
        	.inOut("bean:OrderProcessor?method=processStep2")

Thanks, Jack

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

Re: Camel OnException handling

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

Glad you found the problem and was able to fix it.
And thanks for posting your solution, so we know there was no problem in Camel.


On Mon, Dec 12, 2011 at 1:30 PM, jackkirsten <jk...@hotmail.com> wrote:
> Thanks Claus for a reply.  I apologize for putting this in the wrong forum
> and I've made a note of that for future reference.
>
> I'm using Camel v2.6.  I have found the problem.  I was throwing the
> NullPointerException from the code however the by time it reaches the Camel
> routing it became checked exception so it was going into Exception.class
> block instead of RuntimeException.class block.  After fixing that, it worked
> fine.
>
> Thanks again.
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-OnException-handling-tp5066566p5068125.html
> Sent from the Camel Development mailing list archive at Nabble.com.



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

Re: Camel OnException handling

Posted by jackkirsten <jk...@hotmail.com>.
Thanks Claus for a reply.  I apologize for putting this in the wrong forum
and I've made a note of that for future reference.

I'm using Camel v2.6.  I have found the problem.  I was throwing the
NullPointerException from the code however the by time it reaches the Camel
routing it became checked exception so it was going into Exception.class
block instead of RuntimeException.class block.  After fixing that, it worked
fine.

Thanks again.

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

Re: Camel OnException handling

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

In the future you should post these kind of using Camel questions on
the @user mailing list.
The @dev is for Camel team to discuss developing Camel itself.


However about your question.
What version of Camel are you using?



On Sun, Dec 11, 2011 at 10:16 PM, jackkirsten <jk...@hotmail.com> wrote:
> Hi, I have the following OnException blocks for both generic checked
> exception and runtime exceptions.  When I purposely throw the runtime
> exception such as (NullPointerException) from the process method, only
> Exception.class block is executed and NOT the Runtime.Exception block.  Why
> is it doing this?  How do I fix this so that the appropriate exceptions go
> to the correct onException blocks?
>
> from("seda://OrderID")
>    .routeId("OrderProcessorRoute")
> *    .onException(RuntimeException.class).maximumRedeliveries(0)
>        .handled(true)
>        .log("***** Some Runtime Exceptions Occured. *****")
>        .inOut("direct:exceptionHandling")
>        .end()
>    .onException(Exception.class).maximumRedeliveries(5)
>        .redeliveryDelay(6000)
>        .handled(true)
>        .log("***** Some Checked Exceptions Occured. *****")
>       .inOut("direct:exceptionHandling")
>       .end()
> *
>        .transacted("TestTXPolicy")
>                .inOut("bean:OrderProcessor?method=processStep1")
>                .inOut("bean:OrderProcessor?method=processStep2")
>
> Thanks, Jack
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-OnException-handling-tp5066566p5066566.html
> Sent from the Camel Development mailing list archive at Nabble.com.



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