Hello All,
Here is a simple route that will catch an exception:
<from uri="file:/dropOff"/>
<convertBodyTo type="java.lang.String"/>
<to uri="bean:authorizationBean"/>
<onException>
<exception>java.lang.Exception</exception>
<redeliveryPolicy maximumRedeliveries="0"/>
<handled>
<constant>true</constant>
</handled>
<bean ref="errorResponseBean"
method="createErrorResponse"/>
<convertBodyTo type="java.lang.String"/>
<to uri="file:/error?append=false"/>
</onException>
<to uri="activemq:SSAF.WorkflowProcessingQueue"/>
In the error response bean, I try to get the exception from the Exchange
with no luck:
exchange.isFailed(); //this is false
exchange.getException(); //this is null
However, I can get it from the message. While debugging, I saw it as a
property:
Exception ssafException = (Exception)
exchange.getProperty("CamelCauseException");
Am I doing something wrong here?
Also, if I go the reliable messaging route and send the error message to an
error queue first and then to a bean, I am unable to get the exception using
the property CamelCauseException. I think this is because exceptions can be
sent as part of the activemq message. I recall reading a feature for this
might be available in 2.0.
What I would like to do is have any errors that are thrown by any route sent
to an error processing queue and then have a bean that handles all of them.
The bean will go into the Exchange and get the exception. Depending on the
type of exception, it will produce a different custom xml error to send back
to the client. I can do the last part, but am having problems getting that
exception.
Cheers,
Yogesh
--
View this message in context:
http://www.nabble.com/not-getting-exception-from-exchange-tp20926633s22882p20926633.html
Sent from the Camel - Users mailing list archive at Nabble.com.