On Tue, Nov 2, 2010 at 5:48 PM, paul botta <[email protected]> wrote:
>
> Hi Claus - Thank-you for your quick reply. I apologize for my lack of
> experience with camel, but I am unsure how to accomplish the requirement of
> adding the reason an order failed to the message and sending that message to
> an error queue.
>
> Is there a way to override the rollback behavior or is there a way I can
> programatically re-route the message to an error queue from within the
> POJO's error handling code?
>
> This is a show stopper for me as the client needs to be able to communicate
> the reason an order failed to an internal user.
In the processor you do something like this
// set a custom message why we failed
exchange.getOut().setBody("We failed because of we dont like milk");
// mark it as a fault
exchange.getOut().setFault(true);
In the RouteBuilder you enable fault handling
configure() {
context.setHandleFault(true);
from("xxx")
}
See for example this unit test (note that you dont have to set an
exception as the body if you dont like to)
https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/HandleFaultPerRouteTest.java
>
> Thank-you for any insight you can provide.
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/OnException-appears-to-roll-back-message-state-Need-help-in-understanding-tp3245784p3247023.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/