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: Splitter StopOnException doesn't forward the exception on the Exchange
Date Sat, 11 Jun 2011 17:32:57 GMT
On Wed, Jun 8, 2011 at 5:31 PM, gsilverman
<gsilverman@dispensingsolutionsinc.com> wrote:
> I have the following route which uses stopOnException to catch exceptions:
>
> <route errorHandlerRef="queryFormularyError">
> <from uri="seda:createRx" />
>            <split strategyRef="aggregatorStrategy"
> parallelProcessing="true" stopOnException="true">
>                  <method bean="processSegment" method="split" />
>                  <bean ref="processSegment" method="process" />
>            </split>
>      <to uri="direct:dispense" />
> </route>
>
> The processSegment bean in the above route can throw the following
> exception:
>
> throw new Exception("Product, " + vendorndc + ", is not in formulary")
>
> I want the caught exception to be processed by the errorHandlerRef in the
> route element  but when I call
> exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class) in the
> error handler, the exception getMessage() method returns null, not the
> message in the thrown exception.
>

Ah okay so there is an Exception. Check what type the exception is.
The caused exception could be wrapped.
So there may be a cause on the exception, and if you drill down it
most likely contain your exception =  new Exception("Product, " +
vendorndc + ", is not in formulary")

> Here is my error handler:
>
> public class QueryFormularyErrorHandler implements Processor{
>      private static final transient Logger LOG =
> LoggerFactory.getLogger(QueryFormularyErrorHandler.class);
>      public void process(Exchange exchange) throws Exception {
>            Exception e = exchange.getProperty(Exchange.EXCEPTION_CAUGHT,
> Exception.class);
>
>            LOG.info("Query formulary error: " + e.getMessage());
>            exchange.getIn().setBody(e.getMessage());
>      }
>
> }
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Splitter-StopOnException-doesn-t-forward-the-exception-on-the-Exchange-tp4469882p4469882.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Mime
View raw message