Hi,

The exception handler (MyErrorHandler) only comes into play once the file is
read and routed to the to(destinationURI). The exception handler cannot come
into play if there is a problem setting up a Consumer connection in the
from(sourceURI).
 
This is natural since if there is a problem with setting up the ftp
connection the sourceURI, the route will not be started by the camelcontext.

Hope this helps.

Cheers,

Ashwin...

  

/U 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).end().
>       to("ftp://u...@server?....";).end()
> is working if I cant connect to ftp server; but
> 
> 
> from("ftp://u...@server?....";).onException(Exception.class).process(MyErrHandler).end().
>      to("file://a.log").end()
> not invoking MyErrHandler if server not online.
> 
> why this difference in behavior? 
> 
> 
> 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...@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
>> 
>> 
> 
> 


-----
--- 
Ashwin Karpe, Principal Consultant, PS - Opensource Center of Competence 
Progress Software Corporation
14 Oak Park Drive
Bedford, MA 01730
--- 
+1-972-304-9084 (Office) 
+1-972-971-1700 (Mobile) 
---- 
Blog: http://opensourceknowledge.blogspot.com/


-- 
View this message in context: 
http://old.nabble.com/onException%28%29-tp28008233p28023140.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to