You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by sa_james <sa...@hotmail.com> on 2016/12/16 11:08:46 UTC

Catching Exception

Does Camel catch Exceptions that occur in the first Producer in a route?

lets say I have this:

*onException(Exception.class).to("log:exception ${Body}")
*from("sjms:queue").to("log:test ${Body}")

If I shut down the Queue, an exception is throws in the console but camel
does not log it.
Am I understanding this wrong?



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

Re: Catching Exception

Posted by Claus Ibsen <cl...@gmail.com>.
I logged a ticket to improve sjms-batch. However for sjms its more
tricky. And also mind that each JMS client may have their own error
handling / failover et all.
https://issues.apache.org/jira/browse/CAMEL-10615

On Sat, Dec 17, 2016 at 4:03 PM, Claus Ibsen <cl...@gmail.com> wrote:
> Not all components support the bridge error handler.
>
> As said its component specific, and some special ones like the JMS
> based do not as they have their own JMS client code / logic and how
> errors is dealt with.
>
> Often they have failover / retry options in the JMS client, eg
> ActiveMQ has some special options etc. IBM WebSphere may have some
> etc.
>
> On Sat, Dec 17, 2016 at 1:43 PM, sa_james <sa...@hotmail.com> wrote:
>> So I went back and read the book again, but it does not show how to handle
>> exception outside of the routing engine. I check the file consumer example
>> and tried to apply it, but it did not work. This is what I did:
>>
>> /onException(classOf[Exception]).to("log:was-caught ${body}")
>>
>> from("batch-sjms:test.foo?consumer.bridgeErrorHandler=true").to("log:test")/
>>
>> I was excepting an IOException (First ConnectException and Subsequent
>> DisconnectException) to be caught, but that was not the case.
>> What am I missing?
>>
>>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/Catching-Exception-tp5791552p5791630.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Catching Exception

Posted by sa_james <sa...@hotmail.com>.
Oh I see. 
Yes I know that ActiveMQ can do that. WebSphere does support it too, but to
a lesser extend than ActiveMQ. If WebSphere does not signal to the client
that a reconnect is allowed, the client is going to crash.
Anyway...
Is it possible that Apache Camel is the greatest Library ever created in the
Java World?



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

Re: Catching Exception

Posted by Claus Ibsen <cl...@gmail.com>.
Not all components support the bridge error handler.

As said its component specific, and some special ones like the JMS
based do not as they have their own JMS client code / logic and how
errors is dealt with.

Often they have failover / retry options in the JMS client, eg
ActiveMQ has some special options etc. IBM WebSphere may have some
etc.

On Sat, Dec 17, 2016 at 1:43 PM, sa_james <sa...@hotmail.com> wrote:
> So I went back and read the book again, but it does not show how to handle
> exception outside of the routing engine. I check the file consumer example
> and tried to apply it, but it did not work. This is what I did:
>
> /onException(classOf[Exception]).to("log:was-caught ${body}")
>
> from("batch-sjms:test.foo?consumer.bridgeErrorHandler=true").to("log:test")/
>
> I was excepting an IOException (First ConnectException and Subsequent
> DisconnectException) to be caught, but that was not the case.
> What am I missing?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Catching-Exception-tp5791552p5791630.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Catching Exception

Posted by S AR <sa...@hotmail.com>.
Sadly,

sjms does not throw any exception when the connection is gone. At least when testing with ActiveMQ.

batch-sjms does though.



On 18.12.2016 14:07, Claus Ibsen wrote:

Hi

Btw what exceptions / stacktraces etc do you see from the logs? It can
help us to see if we can improve the camel-sjms component even more.

I am just fixing the batch consumer to allow the bridge

On Sat, Dec 17, 2016 at 1:43 PM, sa_james <sa...@hotmail.com> wrote:


So I went back and read the book again, but it does not show how to handle
exception outside of the routing engine. I check the file consumer example
and tried to apply it, but it did not work. This is what I did:

/onException(classOf[Exception]).to("log:was-caught ${body}")

from("batch-sjms:test.foo?consumer.bridgeErrorHandler=true").to("log:test")/

I was excepting an IOException (First ConnectException and Subsequent
DisconnectException) to be caught, but that was not the case.
What am I missing?



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








Re: Catching Exception

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

Btw what exceptions / stacktraces etc do you see from the logs? It can
help us to see if we can improve the camel-sjms component even more.

I am just fixing the batch consumer to allow the bridge

On Sat, Dec 17, 2016 at 1:43 PM, sa_james <sa...@hotmail.com> wrote:
> So I went back and read the book again, but it does not show how to handle
> exception outside of the routing engine. I check the file consumer example
> and tried to apply it, but it did not work. This is what I did:
>
> /onException(classOf[Exception]).to("log:was-caught ${body}")
>
> from("batch-sjms:test.foo?consumer.bridgeErrorHandler=true").to("log:test")/
>
> I was excepting an IOException (First ConnectException and Subsequent
> DisconnectException) to be caught, but that was not the case.
> What am I missing?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Catching-Exception-tp5791552p5791630.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Re: Catching Exception

Posted by sa_james <sa...@hotmail.com>.
So I went back and read the book again, but it does not show how to handle
exception outside of the routing engine. I check the file consumer example
and tried to apply it, but it did not work. This is what I did:

/onException(classOf[Exception]).to("log:was-caught ${body}")

from("batch-sjms:test.foo?consumer.bridgeErrorHandler=true").to("log:test")/

I was excepting an IOException (First ConnectException and Subsequent
DisconnectException) to be caught, but that was not the case. 
What am I missing?



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

Re: Catching Exception

Posted by Claus Ibsen <cl...@gmail.com>.
See this FAQ
http://camel.apache.org/why-does-my-file-consumer-not-pick-up-the-file-and-how-do-i-let-the-file-consumer-use-the-camel-error-handler.html

And if you have a copy of the Camel in Action book its explained in
the error handler chapter.


On Fri, Dec 16, 2016 at 12:08 PM, sa_james <sa...@hotmail.com> wrote:
> Does Camel catch Exceptions that occur in the first Producer in a route?
>
> lets say I have this:
>
> *onException(Exception.class).to("log:exception ${Body}")
> *from("sjms:queue").to("log:test ${Body}")
>
> If I shut down the Queue, an exception is throws in the console but camel
> does not log it.
> Am I understanding this wrong?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Catching-Exception-tp5791552.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2