The Camel error handler is covered in chapter 5 in the Camel book if you want to get to the bottom of understanding it.
Also there is documentation at Camel web site http://camel.apache.org/error-handling-in-camel.html The Camel error handler will snapshot the message before its being processed. And in case the processing failed, it will use the snapshot message when handling the error. So its correct behavior. In the JBI/ServiceMix "world" you can use fault messages instead of exceptions. getOut().setFault(true); And then if you still want Camel onException to handle the fault messages you need to enable this using .handleFault() in the Camel route On Mon, Nov 1, 2010 at 10:37 PM, paul botta <[email protected]> wrote: > > Hi - I am need of some help in understanding more about exception handling. > I am using Camel 2.2 inside of Servicemix 3.3.2 (along with XMLBeans and > Spring). > > What I need to happen is that the nature of the exception is populated > inside the message and then forwarded to an error queue. What *appears* to > be happening is that the message prior to it being processed by the bean is > being forwarded into the queue. If you have any suggestions, please let me > know - Thanks. > > Verification Bean > ---------------- > > if ( goodOrder ) > exchange.getOut().setBody(orderDocument.xmlText()); > else { > this.processOrderError(orderDocument, errorLog.toString()); > exchange.getOut().setHeader(Exchange.FILE_NAME, > > getOrderNumber(orderDocument)+".error."+System.nanoTime()+".xml"); > > System.out.println(orderDocument.getClarisonicWebOrder().getProcessing().toString()); > exchange.getOut().setBody(orderDocument.xmlText()); > throw new Exception("Failed Order Verification"); > } > > // Note: the processOrderMessage() inserts the error message in a defined > area. The subsequent System.out.println() confirms that the error message > is correctly inserted. > > > My Spring is: > > <camelContext id="camelContext" > xmlns="http://camel.apache.org/schema/spring"> > <package>myPackage</package> > > <onException> > <exception>java.lang.Exception</exception> > <redeliveryPolicy maximumRedeliveries="0" /> > <handled> > <constant>true</constant> > </handled> > <to uri="jms://queue/order-error" /> > </onException> > > <route> > <from uri="jms://queue/order-file-processor"/> > <pipeline> > <bean ref="orderVerifier" method="processMessage"/> > <bean ref="orderRuleEnforcer" method="processMessage"/> > <bean ref="orderPostprocessor" method="processMessage"/> > <to uri="jms://queue/order-data-processor"/> > </pipeline> > </route> > > </camelContext> > > > The XML that outputs from the order-error queue does not contain the error > message (that I have confirmed in the aforementioned System.out method). > Thanks for your help. > -- > View this message in context: > http://camel.465427.n5.nabble.com/OnException-appears-to-roll-back-message-state-Need-help-in-understanding-tp3245784p3245784.html > Sent from the Camel - Users mailing list archive at Nabble.com. > -- Claus Ibsen ----------------- FuseSource Email: [email protected] Web: http://fusesource.com Twitter: davsclaus Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/
