camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: onException()
Date Thu, 25 Mar 2010 05:45:00 GMT
On Wed, Mar 24, 2010 at 11:30 PM, /U <uma_rk@comcast.net> wrote:
>
> thnaks for the help - it works. Only problem:
> if connection to toUri fails, MyErrorhandler is
> invoked; but if connection to fromUri fails,
> MyErrorHandler not invoked!
>
> for example,
>
> from("file://a.log").onException(Exception.class).process(MyErrHandler).to("ftp://user@server?....").end()
> is working if I cant connect to ftp server; but
>
>
> from("ftp://user@server?....").onException(Exception.class).process(MyErrHandler).to("file://a.log").end()
> not invoking MyErrHandler if server not online.
>
> why this difference in behavior?
>

Read chapter 5 in the Camel in Action book which explains error
handling in great details.

And see PollingConsumerPollStrategy if you want to do some custom code
if the "from" fails
http://camel.apache.org/polling-consumer.html

>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>> onException should be set right after from. So you route should be
>>
>>        from(fromUri)
>>           .onException(Exception.class).process(new
>> MyErrorHandler(fromUri)).end();
>>           .to(toUri);
>>
>> And you can use .toF to pass arguments (like String.format). Or its
>> simply just Java so you can do .to("xxx" + "?yyy=zzz");
>>
>>
>> On Tue, Mar 23, 2010 at 11:43 PM, /U <uma_rk@comcast.net> wrote:
>>>
>>> Camel: 2.2.0:
>>>
>>> i have route builder which adds a route as follows with a
>>> deadLetterChannel
>>> as a fallback error handler and an onException fork:
>>>
>>>
>>>       errorHandler(deadLetterChannel("bean:myBean?method=processError"));
>>>       //
>>>       from(fromUri).to(toUri).end().
>>>                        onException(Exception.class).process(new
>>> MyErrorHandler(fromUri)).stop();
>>>
>>>
>>> Problem is: when the message cannot be routed to the destination endpoint
>>> (say, because the endpoint URI is not reachable)
>>> the onException nominated ErrorHandler is never invoked; instead the
>>> deadLetterChannel()
>>> is invoked. This would be fine except for the fact that I need an
>>> application context
>>> in the error handler for cleanup: while I am able to pass the required
>>> context to my
>>> onException error handler (as shown above), I am not sure how to do that
>>> with the
>>> deadLetterChannel.
>>>
>>> Questions:
>>>   - why isn't onException() method invoked?
>>>   - is there a way to pass an arbitrary data to a bean which is used as
>>> an
>>> endpoint. Eg:
>>>         to("bean:myBean?method=processError&arg="+fromUri)
>>>
>>> regardds,
>>>
>>> /U
>>>
>>> --
>>> View this message in context:
>>> http://old.nabble.com/onException%28%29-tp28008233p28008233.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>>
>
> --
> View this message in context: http://old.nabble.com/onException%28%29-tp28008233p28022280.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Mime
View raw message