camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ychawla <>
Subject not getting exception from exchange
Date Wed, 10 Dec 2008 00:12:44 GMT

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"/>
	          <redeliveryPolicy maximumRedeliveries="0"/>
			<bean ref="errorResponseBean" method="createErrorResponse"/>     
			<convertBodyTo type="java.lang.String"/>
    			<to uri="file:/error?append=false"/>
	  <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
Exception ssafException = (Exception)

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

View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message