You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by atg roxx <at...@gmail.com> on 2012/02/10 14:56:25 UTC
onException is not getting called for exception which are not
generated in camel route
Hi ,
I have a situation:
In general in a camel when we have any exception in a route the onException
is called.
for example :
onException definition:
-------------------------------
onException( MyException mye)
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
SOP("got my exception");
}
});
camel route:
---------------------
from(jms:abc)
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
throw new MyException();
}
});
But if i throw an exception in process block of onException it is not
getting caught in other onException defined.
for example:
got and MyException-----------
onException( MyException mye)
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
// in processor block throwing mytestexception
throw new MyTestException();
}
});
I have defined onException which can handle MyTestException. But this is
not getting called :(
-------------------------------------
onException( MyTestException myte)
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
SOP("got my MyTestException ");
}
});
Could please anyone let me know why it is happening??? Also how can we
achieve it.
--cheers,
atgroxx
Re: onException is not getting called for exception which are not
generated in camel route
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
You cannot do onException while doing onException, as this gets
complicated, and you could potentially end up in a endless loop or
whatever.
When the 2nd exception is detected Camel will log this at ERROR level
using a FatalFallbackErrorHandler.
On Fri, Feb 10, 2012 at 2:56 PM, atg roxx <at...@gmail.com> wrote:
> Hi ,
>
>
> I have a situation:
>
> In general in a camel when we have any exception in a route the onException
> is called.
>
> for example :
>
> onException definition:
> -------------------------------
> onException( MyException mye)
> .process(new Processor() {
> @Override
> public void process(Exchange exchange) throws Exception {
> SOP("got my exception");
> }
> });
>
> camel route:
> ---------------------
> from(jms:abc)
> .process(new Processor() {
> @Override
> public void process(Exchange exchange) throws Exception {
> throw new MyException();
> }
> });
>
>
>
> But if i throw an exception in process block of onException it is not
> getting caught in other onException defined.
>
> for example:
>
> got and MyException-----------
> onException( MyException mye)
> .process(new Processor() {
> @Override
> public void process(Exchange exchange) throws Exception {
> // in processor block throwing mytestexception
>
> throw new MyTestException();
> }
> });
>
>
> I have defined onException which can handle MyTestException. But this is
> not getting called :(
> -------------------------------------
> onException( MyTestException myte)
> .process(new Processor() {
> @Override
> public void process(Exchange exchange) throws Exception {
>
> SOP("got my MyTestException ");
> }
> });
>
>
> Could please anyone let me know why it is happening??? Also how can we
> achieve it.
>
>
> --cheers,
> atgroxx
--
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/