On Fri, Aug 24, 2012 at 10:27 PM, Marco Mistroni <mmistr...@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: cib...@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Reply via email to