camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marco Mistroni <mmistr...@gmail.com>
Subject Re: Camel Exception Handling issue
Date Sat, 25 Aug 2012 10:38:08 GMT
Hello Claus
  thanks a lot for the tip!

w/kindest regards
 marco

On Sat, Aug 25, 2012 at 9:02 AM, Claus Ibsen <claus.ibsen@gmail.com> wrote:

> On Fri, Aug 24, 2012 at 10:27 PM, Marco Mistroni <mmistroni@gmail.com>
> wrote:
> > HI all
> >  i have implemented exception handling in my camel app this way
> >
> > <camel:route>
> >             <camel:from uri="seda:processBloombergShares" />
> >             <camel:bean ref="bloombergServiceActivator"
> method="fetchData"
> > />
> >             <camel:multicast>
> >                 <camel:to
> > uri="bean:sharesEndpointBean?method=handleBloombergShare" />
> >                 <camel:to uri="seda:report" />
> >             </camel:multicast>
> >             <camel:onException>
> >                 <camel:exception>java.lang.Exception</camel:exception>
> >                 <camel:handled>
> >                     <camel:constant>true</camel:constant>
> >                 </camel:handled>
> >                 <camel:to
> > uri="bean:exceptionHandler?method=handleException" />
> >             </camel:onException>
> >  </camel:route>
> >
> > and Here's my exception handler
> >
> > public void handleException(Exchange exchange) {
> >         LOGGER.info("-------Handling exceptions with exchange:");
> >         LOGGER.info("exception:" + exchange.getException());
> >
> > However it appears that exchange.getException() is null somehow, as from
> > the logs i can see
> >
> > INFO ExceptionHandler * exception:null
> >
> >
> > what am i doing incorrect?  shall i remove  <camel:handled>?
> >
>
> You handle the exception and thus it get cleared from the exchange.
> You can get the caused exception from a property on the exchange. Or
> even easier just add a 2nd parameter to the method with a type of
> java.lang.Exception and Camel will pass in the caused exception for
> you.
>
>
>
> >
> > w/kindest regards
> >  marco
>
>
>
> --
> 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
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message