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.

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.

Reply via email to