You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by vishal1981 <vi...@ericsson.com> on 2012/09/05 06:56:02 UTC

Getting consumer endpoint details or exchange headers in custom ExceptionHandler

Hi,
I am implementing the ExceptionHandler to catch exceptions that happen while
fetching a file remotely via FTP (e.g. IOExceptions etc.).
In my custom ExceptionHandler I need a way to figure out which endpoint/FTP
URI failed since I have more than one.
The ExceptionHandler method -handleException which gets invoked only gets
the exception and not the originating FTP endpoint. How can I possibly find
that out. I have an exchange header but I guess the exchange is not even
constructed if the first endpoint fails.
The Exception handler is an Stateless session bean and will be shared across
several routes.

I am using 2.9 release. 
Thanks in advace,
-v-



--
View this message in context: http://camel.465427.n5.nabble.com/Getting-consumer-endpoint-details-or-exchange-headers-in-custom-ExceptionHandler-tp5718633.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Getting consumer endpoint details or exchange headers in custom ExceptionHandler

Posted by vishal1981 <vi...@ericsson.com>.
Thanks for your replies.
I am indeed using consumer.exceptionHandler however when I configure an FTP
endpoint to FTP to a non-existing FTP server my exception handler is never
fired. Is it because I have to add an additional PollingConsumerPollStrategy
to handle such kind of exceptions?
I am not sure which exceptions will be thrown during prepollcheck and during
actual fetching of the file and will the exception handler not be invoked
for exceptions that get thrown during pre-poll check?



--
View this message in context: http://camel.465427.n5.nabble.com/Getting-consumer-endpoint-details-or-exchange-headers-in-custom-ExceptionHandler-tp5718633p5718824.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Getting consumer endpoint details or exchange headers in custom ExceptionHandler

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

During routing a message you can use the Camel error handling.
http://camel.apache.org/error-handling-in-camel.html

Such as an onException to deal with the exception. The exchange gets
enriched with a header/property with the last endpoint it was sent to,
so you can grab that detail to known which ftp endpoint failed, you
tried to send the message to.



On Wed, Sep 5, 2012 at 11:22 PM, vishal1981
<vi...@ericsson.com> wrote:
> Guys please if you can comment? I am kinda stuck
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Getting-consumer-endpoint-details-or-exchange-headers-in-custom-ExceptionHandler-tp5718633p5718694.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: Getting consumer endpoint details or exchange headers in custom ExceptionHandler

Posted by vishal1981 <vi...@ericsson.com>.
Guys please if you can comment? I am kinda stuck



--
View this message in context: http://camel.465427.n5.nabble.com/Getting-consumer-endpoint-details-or-exchange-headers-in-custom-ExceptionHandler-tp5718633p5718694.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Getting consumer endpoint details or exchange headers in custom ExceptionHandler

Posted by Willem jiang <wi...@gmail.com>.
I'm not sure if you are using consumer.exceptionHandler[1] to do this kind of job.
There are some enhancement since Camel 2.10.0, you can define a consumer.bridgeErrorHandler[2] to catch the exception if it is thrown from the file of ftp consumer.

[1]http://camel.apache.org/file2.html#File2-HowtousetheCamelerrorhandlertodealwithexceptionstriggeredoutsidetheroutingengine

[2]http://camel.apache.org/file2.html#File2-Usingconsumer.bridgeErrorHandler 

-- 
Willem Jiang

FuseSource
Web: http://www.fusesource.com (http://www.fusesource.com/)
Blog: http://willemjiang.blogspot.com (http://willemjiang.blogspot.com/) (English)
          http://jnn.javaeye.com (http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang 
Weibo: willemjiang





On Wednesday, September 5, 2012 at 12:56 PM, vishal1981 wrote:

> Hi,
> I am implementing the ExceptionHandler to catch exceptions that happen while
> fetching a file remotely via FTP (e.g. IOExceptions etc.).
> In my custom ExceptionHandler I need a way to figure out which endpoint/FTP
> URI failed since I have more than one.
> The ExceptionHandler method -handleException which gets invoked only gets
> the exception and not the originating FTP endpoint. How can I possibly find
> that out. I have an exchange header but I guess the exchange is not even
> constructed if the first endpoint fails.
> The Exception handler is an Stateless session bean and will be shared across
> several routes.
> 
> I am using 2.9 release. 
> Thanks in advace,
> -v-
> 
> 
> 
> --
> View this message in context: http://camel.465427.n5.nabble.com/Getting-consumer-endpoint-details-or-exchange-headers-in-custom-ExceptionHandler-tp5718633.html
> Sent from the Camel - Users mailing list archive at Nabble.com (http://Nabble.com).




Re: Getting consumer endpoint details or exchange headers in custom ExceptionHandler

Posted by vishal1981 <vi...@ericsson.com>.
Thanks.



--
View this message in context: http://camel.465427.n5.nabble.com/Getting-consumer-endpoint-details-or-exchange-headers-in-custom-ExceptionHandler-tp5718633p5719061.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Getting consumer endpoint details or exchange headers in custom ExceptionHandler

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Sep 5, 2012 at 6:56 AM, vishal1981
<vi...@ericsson.com> wrote:
> Hi,
> I am implementing the ExceptionHandler to catch exceptions that happen while
> fetching a file remotely via FTP (e.g. IOExceptions etc.).
> In my custom ExceptionHandler I need a way to figure out which endpoint/FTP
> URI failed since I have more than one.
> The ExceptionHandler method -handleException which gets invoked only gets
> the exception and not the originating FTP endpoint. How can I possibly find
> that out. I have an exchange header but I guess the exchange is not even
> constructed if the first endpoint fails.
> The Exception handler is an Stateless session bean and will be shared across
> several routes.
>

I have logged a ticket to improve the ExceptionHandler in a future Camel release
https://issues.apache.org/jira/browse/CAMEL-5587

> I am using 2.9 release.
> Thanks in advace,
> -v-
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Getting-consumer-endpoint-details-or-exchange-headers-in-custom-ExceptionHandler-tp5718633.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