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 Wed, 24 Mar 2010 05:29:35 GMT
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

Mime
View raw message