title: Camel/ActiveMQ Transactions, Redelivery and DLQs
body: <p>Using Fabric8 379 build. </p>
  
  <p>Currently struggling with ActiveMQ &amp; Camel getting the desired behaviours of TransactionErrorHandler to work as expected. </p>
  
  <p>Firstly as per the Camel error handler documentation (<a href="http://camel.apache.org/error-handler.html" rel="nofollow">http://camel.apache.org/error-handler.html</a>)  if I invoke the TransactionErrorHandler as suggested i.e. </p>
  
  <pre><code>&lt;errorHandler id="txEH" type="TransactionErrorHandler"&gt;
  &lt;redeliveryPolicy logStackTrace="false" logExhausted="false" maximumRedeliveries="3"/&gt;
  &lt;/errorHandler&gt;
  </code></pre>
  
  <p>I get an error: </p>
  
  <pre><code>Caused by: org.xml.sax.SAXParseException: cvc-enumeration-valid: Value 'TransactionErrorHandler' is not facet-valid with respect to enumeration '[DeadLetterChannel, DefaultErrorHandler, NoErrorHandler, LoggingErrorHandler]'. It must be a value from the enumeration.
  </code></pre>
  
  <p>Which is fair enough, I guess TransactionErrorHandler has been removed from the schema and has to be invoked differently? So if I go the alternative route and specify a TransactionErrorHandler bean like so: </p>
  
  <pre><code>&lt;bean id="transactionErrorHandler"
      class="org.apache.camel.spring.spi.TransactionErrorHandlerBuilder"&gt;
      &lt;property name="deadLetterUri" value="activemq:queue:ActiveMQ.DLQ" /&gt;
      &lt;property name="redeliveryPolicy" ref="redeliveryPolicy" /&gt; 
  &lt;/bean&gt;
  
  &lt;bean id="redeliveryPolicy" class="org.apache.camel.processor.RedeliveryPolicy"&gt;
      &lt;property name="backOffMultiplier" value="2" /&gt;
      &lt;property name="maximumRedeliveries" value="2" /&gt;
      &lt;property name="redeliveryDelay" value="1000" /&gt;
      &lt;property name="useExponentialBackOff" value="true" /&gt;
  &lt;/bean&gt; 
  </code></pre>
  
  <p>I can successfully use this within my route by specifying errorHandlerRef="transactionErrorHandler". However when testing this scenario, the redeliveryPolicy is completely ignored, with redelivery attempts being 6 (default) rather than the 2 specified above. I am hoping someone can point me in the right direction around how to properly specify a TransactionErrorHandler within a route. Below is my current test blueprint.xml, which is deployed onto a fabric:</p>
  
  <pre><code>&lt;blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
      xmlns:camel="http://camel.apache.org/schema/blueprint"
      xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
                                http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd
                                http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd 
                                http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.0.0.xsd"&gt;
  
      &lt;!-- blueprint property placeholders --&gt;
      &lt;cm:property-placeholder id="test-adapter" persistent-id="uk.test.transactions"&gt;
          &lt;cm:default-properties&gt;
              &lt;cm:property name="amqBrokerURL" value="discovery:(fabric:platform)" /&gt;
              &lt;cm:property name="amqBrokerUserName" value="admin" /&gt;
              &lt;cm:property name="amqBrokerPassword" value="admin" /&gt;
          &lt;/cm:default-properties&gt;
      &lt;/cm:property-placeholder&gt;
  
      &lt;camelContext xmlns="http://camel.apache.org/schema/blueprint" id="TestRouteContext" useMDCLogging="true"&gt;
  
          &lt;!-- &lt;errorHandler id="txEH" type="TransactionErrorHandler"&gt;
              &lt;redeliveryPolicy logStackTrace="false"
                  logExhausted="false" /&gt;
          &lt;/errorHandler&gt; --&gt;
  
          &lt;route id="platform-test-route" errorHandlerRef="txEH"&gt;
              &lt;from uri="activemq:queue:test-queue-in" /&gt;
              &lt;transacted ref="transactionPolicy" /&gt;
                      &lt;!-- Basic Bean that logs a message --&gt;
              &lt;bean ref="stubSuccess" /&gt;
                      &lt;!-- Basic Bean that throws a java.lang.Exception--&gt;
              &lt;bean ref="stubFailure" /&gt;
              &lt;to uri="activemq:queue:test-queue-out" /&gt;
          &lt;/route&gt;
  
      &lt;/camelContext&gt;
  
      &lt;bean id="stubSuccess" class="uk.test.transactions.stubs.StubSuccess" /&gt;
  
      &lt;bean id="stubFailure" class="uk.test.transactions.stubs.StubFailure" /&gt;
  
      &lt;bean id="transactionErrorHandler"
          class="org.apache.camel.spring.spi.TransactionErrorHandlerBuilder"&gt;
          &lt;property name="deadLetterUri" value="activemq:queue:ActiveMQ.DLQ" /&gt;
          &lt;property name="redeliveryPolicy" ref="redeliveryPolicy" /&gt; 
      &lt;/bean&gt;
  
      &lt;bean id="transactionPolicy" class="org.apache.camel.spring.spi.SpringTransactionPolicy"&gt;
          &lt;property name="transactionManager" ref="jmsTransactionManager" /&gt;
          &lt;property name="propagationBehaviorName" value="PROPAGATION_REQUIRED" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="jmsTransactionManager"
          class="org.springframework.jms.connection.JmsTransactionManager"&gt;
          &lt;property name="connectionFactory" ref="jmsPooledConnectionFactory" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent"&gt;
          &lt;property name="connectionFactory" ref="jmsPooledConnectionFactory" /&gt;
          &lt;property name="transacted" value="true" /&gt;
          &lt;property name="transactionManager" ref="jmsTransactionManager" /&gt;
          &lt;property name="cacheLevelName" value="CACHE_CONSUMER" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="jmsPooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory"
          init-method="start" destroy-method="stop"&gt;
          &lt;property name="maxConnections" value="1" /&gt;
          &lt;property name="connectionFactory" ref="jmsConnectionFactory" /&gt;
      &lt;/bean&gt;
  
  &lt;!--    &lt;bean id="redeliveryPolicy" class="org.apache.activemq.RedeliveryPolicy"&gt;
          &lt;property name="backOffMultiplier" value="2" /&gt;
          &lt;property name="initialRedeliveryDelay" value="2000" /&gt;
          &lt;property name="maximumRedeliveries" value="2" /&gt;
          &lt;property name="redeliveryDelay" value="1000" /&gt;
          &lt;property name="useExponentialBackOff" value="true" /&gt;
      &lt;/bean&gt; --&gt;
  
      &lt;bean id="redeliveryPolicy" class="org.apache.camel.processor.RedeliveryPolicy"&gt;
          &lt;property name="backOffMultiplier" value="2" /&gt;
          &lt;property name="maximumRedeliveries" value="2" /&gt;
          &lt;property name="redeliveryDelay" value="1000" /&gt;
          &lt;property name="useExponentialBackOff" value="true" /&gt;
      &lt;/bean&gt; 
  
      &lt;bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"&gt;
          &lt;property name="brokerURL" value="${amqBrokerURL}" /&gt;
          &lt;property name="userName" value="${amqBrokerUserName}" /&gt;
          &lt;property name="password" value="${amqBrokerPassword}" /&gt;
          &lt;property name="watchTopicAdvisories" value="false" /&gt;
          &lt;!-- &lt;property name="redeliveryPolicy" ref="redeliveryPolicy" /&gt; --&gt;
      &lt;/bean&gt;
  
  &lt;/blueprint&gt;  
  </code></pre>
  
  <p>If anyone could see where I am going wrong it would be much appreciated. </p>