title: XA transaction for an Apache Camel route consuming ActiveMQ
body: <p>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.</p>
  
  <p>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.</p>
  
  <p>I've taken this example to have a working <a href="https://github.com/CamelCookbook/camel-cookbook-examples/blob/master/camel-cookbook-transactions/src/test/java/org/camelcookbook/transactions/xatransaction/XATransactionTest.java" rel="nofollow">XA setup for Camel with Atomikos</a>. Based on this I created another @Test.</p>
  
  <p>There's a RouteBuilder to create a test route that looks like this:</p>
  
  <pre><code>                from("jms:xa_input?transacted=true")
                      .transacted("PROPAGATION_REQUIRED")
                      .log("Processing message: ${body}")
                      .process(new ThrowExceptionProcessor(new Exception("error)))
                      .to("jms:xa_output");
  </code></pre>
  
  <p>The exception shall simulate a failing destination.</p>
  
  <p>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.</p>
  
  <p>How can I prevent the ActiveMQ consumer from dequeuing the message?</p>