My requirement is to leave messages in the source queue my comsumer polls in ActiveMQ if something goes wrong while processing a given Camel route.
My understanding is that I need to have an XA transaction to handle this. I want to setup Camel via Java DSL. There's no EE container in place.
I've taken this example to have a working XA setup for Camel with Atomikos. Based on this I created another @Test.
There's a RouteBuilder to create a test route that looks like this:
from("jms:xa_input?transacted=true")
.transacted("PROPAGATION_REQUIRED")
.log("Processing message: ${body}")
.process(new ThrowExceptionProcessor(new Exception("error)))
.to("jms:xa_output");
The exception shall simulate a failing destination.
When I now send a message to xa_input (via ActiveMQ's web console) the message gets dequeued from the queue and disappears. It's not routed to xa_output or a DLQ. I did expect the message to stay in xa_input.
How can I prevent the ActiveMQ consumer from dequeuing the message?