4 Replies Latest reply on Feb 2, 2015 9:29 AM by gustavsinder

    Unable to change default maximumRedeliveries for ActiveMQ transactions

    gustavsinder

      Hi,

       

      I've managed to introduce transactions to my camel contexts so that messages are rolled back to ActiveMQ upon exceptions.

      However, I'm unable to change the maximumRedeliveries from the default 6...I want 0 so that messages are immediately placed onto the DLQ.

       

      Snippet of my route:

      <route id="rollbackTest">
        <from uri="activemq:myQueueIn&amp;transacted=true"/>
        <throwException ref="myException"/>
        <to uri="activemq:myQueueOut"/>
      </route>
      
      

       

      I've updated the ActiveMQ config to hold a redeliveryPolicyMap:

              <plugins>
                  <jaasAuthenticationPlugin configuration="karaf"/>
                  <redeliveryPlugin>
                      <redeliveryPolicyMap>
                          <redeliveryPolicyMap>
                              <!-- applies to all queues (using wildcard) -->
                              <redeliveryPolicyEntries>
                                  <redeliveryPolicy queue=">" maximumRedeliveries="1"/>
                              </redeliveryPolicyEntries>
                              <!-- the default fallback policy -->
                              <defaultEntry>
                                  <redeliveryPolicy maximumRedeliveries="1"/>
                              </defaultEntry>
                          </redeliveryPolicyMap>
                      </redeliveryPolicyMap>
                  </redeliveryPlugin>
              </plugins>
      
      

       

      Since I was getting an error I also added this to the broker definition:

      schedulerSupport="true"
      
      

       

      However, I really can't get the setting to take effect. Messages are always retried 6 times before the messages end up on DLQ.

       

      Any help/input appreciated, thanks

        • 1. Re: Unable to change defualt maximumRedeliveries for ActiveMQ transactions
          bharadwaj

          Use Dead letter queue - re-delivery policy

           

           

          • 2. Re: Unable to change defualt maximumRedeliveries for ActiveMQ transactions
            gustavsinder

            As I understand it, a Redelivery policy is configured from the client (Camel in this case) as documented here: http://activemq.apache.org/redelivery-policy.html

            However, as I interpret the documentation on camel transactions, the redelivery and backout mechanism is configured in the backing system (ActiveMQ): http://camel.apache.org/transactional-client.html

             

            I followed the instructions here to set up my redelivery in ActiveMQ: http://activemq.apache.org/message-redelivery-and-dlq-handling.html

             

            Unsure if I'm supposed to configure this in the ActiveMQ broker or in the client.

            • 3. Re: Unable to change default maximumRedeliveries for ActiveMQ transactions
              bibryam

              I have done it by configuring on the client like this:

               

              <bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
                  <property name="brokerURL" value="${esb.activemq.brokerURL}"/>
                  <property name="userName" value="${esb.activemq.username}"/>
                  <property name="password" value="${esb.activemq.password}"/>
                  <property name="redeliveryPolicy" ref="redeliveryPolicy" />
              </bean>
              <bean id="redeliveryPolicy" class="org.apache.activemq.RedeliveryPolicy">
                 <property name="maximumRedeliveries" value="${esb.activemq.maximumRedeliveries}" />

                  </bean>

              • 4. Re: Re: Unable to change default maximumRedeliveries for ActiveMQ transactions
                gustavsinder

                Thanks a lot!

                I got it to work by setting:

                <bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
                  <property name="brokerURL" value="tcp://localhost:61616"/>
                  <property name="userName" value="someuser"/>
                  <property name="password" value="somepassword"/>
                  <property name="redeliveryPolicy" ref="redeliveryPolicy"/>
                </bean>
                
                <bean id="pooledConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory" init-method="start" destroy-method="stop">
                  <property name="maxConnections" value="8"/>
                  <property name="connectionFactory" ref="jmsConnectionFactory"/>
                </bean>
                
                <bean id="jmsConfig" class="org.apache.camel.component.jms.JmsConfiguration">
                  <property name="connectionFactory" ref="pooledConnectionFactory"/>
                  <property name="concurrentConsumers" value="1"/>
                </bean>
                
                <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
                  <property name="configuration" ref="jmsConfig"/>
                  <property name="transacted" value="true"/>
                </bean>
                
                <bean id="redeliveryPolicy" class="org.apache.activemq.RedeliveryPolicy">
                  <property name="maximumRedeliveries" value="0"/>
                </bean>
                
                

                 

                I was previously  using the connection factory without pooling:

                <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
                  <property name="configuration" ref="jmsConfig"/>
                  <property name="transacted" value="true"/>
                  <property name="userName" value="someuser"/>
                  <property name="password" value="somepassword"/>
                </bean>
                
                

                 

                It seems that I need to use a pooled connection factory to be able to use the redelivery policy.