0

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?

mdo
  • 6,961
  • 3
  • 24
  • 26
  • Transactions can be hard to configure correct - you may want to buy that book to read its transaction chapter, or the Camel in Action book (1st or 2nd ed). Or try read the Camel docs on tx: http://camel.apache.org/transactional-client.html – Claus Ibsen Nov 23 '15 at 18:22
  • And you may not need XA, if you only use the same JMS broker then local transactions is much better to use. – Claus Ibsen Nov 23 '15 at 18:22
  • In fact this is only a test scenario. In the end I want to forward the queue messages to a remote SOAP endpoint. And if that fails I need to retry the corresponding message at a later point in time – with the correct message ordering from the queue for the following messages. – mdo Nov 23 '15 at 18:55

0 Answers0