Search code examples
apache-camelapache-servicemix

How to access exception message during redelivery


I want to process failed messages during redelivery phase (works fine at the end of the retry phase). I use a "onRedeliveryRef" in exception but this processor seems to be executed before retry and not after, so the error message seems to be not available (as it is in de default log).

Any Help would be appreciate.

<bean id="myRedeliveryProc" class="com.mycomp.MyRedeliveryProc"/>

This processor just log error message in the process method : log.info("Exceptions:"+exch.getException());

CamelContext :

<redeliveryPolicyProfile id="rpp" maximumRedeliveries=3 redeliveryDelay="5000"/>
<onException onRedeliveryRef="myRedelivryProc" redeliveryPolicyRef="rpp>
      <exception>java.lang.Exception</exception>
       ...
</onException>  

in log :

MyRedeliveryProc                 | 422 | m22 | 1.0.0 | Exceptions:null

Solution

  • Try getting the exception with

    Exception cause = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class);

    as described in

    http://camel.apache.org/why-is-the-exception-null-when-i-use-onexception.html