0 Replies Latest reply on Sep 2, 2013 8:20 AM by Marko S

    HornetQ and DLQ - How to configure Max delivery attemps?

    Marko S Newbie

      I am running JBoss ESB 4.12 and JBoss 6.0.0.Final AS. As far as I can see configuring max-delivery-attempts has no effect.

       

      My scenario and configuration as follows:


      esbcontent/hornetq-jms.xml:

      <?xml version="1.0"?>
      <configuration xmlns="urn:hornetq"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
      
      
        <connection-factory name="ConnectionFactory">
        <connectors>
        <connector-ref connector-name="netty" />
        </connectors>
        <entries>
        <entry name="/ConnectionFactory" />
        <entry name="/XAConnectionFactory" />
        </entries>
        </connection-factory>
      
      
        <queue name="queue1_tx_jms">
        <entry name="queue/queue1_tx_jms" />
      
      
        </queue>
      
      
        <queue name="queue2_gw">
        <entry name="queue/queue2_gw" />
        </queue>
        <queue name="fault_service_queue">
        <entry name="queue/fault_service_queue" />
        </queue>
      </configuration>
      
      
      

       

       

      esbcontent/hornetq-configuration.xml

       

      <?xml version = "1.0" encoding = "UTF-8"?>
      
      
      <configuration xmlns="urn:hornetq"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd">
        <address-settings>
        <!-- override the max-delivery-attempts and dead letter address for the
        example queue -->
        <address-setting match="jms.queue.queue2_gw">
        <max-delivery-attempts>5</max-delivery-attempts>
        <redelivery-delay>5000</redelivery-delay>
              <dead-letter-address>jms.queue.deadLetterQueue</dead-letter-address>
      
      
        </address-setting>
      
      
        <address-setting match="jms.queue.queue1_tx_jms">
               <dead-letter-address>jms.queue.deadLetterQueue</dead-letter-address>
        <max-delivery-attempts>5</max-delivery-attempts>
        <redelivery-delay>5000</redelivery-delay>
        </address-setting>
      
      
        </address-settings>
      
      
      
      
      </configuration>
      
      
      
      

       

       

      esbcontent/META-INF/jboss-esb.xml

      <?xml version="1.0"?>
      <jbossesb parameterReloadSecs="5"
       xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.3.0.xsd"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.3.0.xsd http://anonsvn.jboss.org/repos/labs/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.3.0.xsd">
      <providers>
        <jms-jca-provider connection-factory="XAConnectionFactory" name="JBossMessaging">
         <jms-bus busid="queue1_tx_jms">
          <jms-message-filter dest-name="queue/queue1_tx_jms"
           dest-type="QUEUE" transacted="true"/>
         </jms-bus>
         <jms-bus busid="queue2_gw">
          <jms-message-filter dest-name="queue/queue2_gw" dest-type="QUEUE" transacted="true"/>
         </jms-bus>
         <activation-config>
          <property name="dLQMaxResent" value="1"/>
         </activation-config>
        </jms-jca-provider>
      </providers>
      <services>
        <service category="HelloWorld_ActionESB" description="Says hello"
         invmTransacted="true" name="SayHelloListener">
         <listeners>
          <jms-listener busidref="queue1_tx_jms" maxThreads="1" name="JMS-ESBListener">
           <jms-message-filter dest-name="queue/queue1_tx_jms"
            dest-type="QUEUE" transacted="true"/>
          </jms-listener>
          <jms-listener busidref="queue2_gw" is-gateway="true" maxThreads="1" name="queue2_gw">
           <jms-message-filter dest-name="queue/queue2_gw" dest-type="QUEUE" transacted="true"/>
          </jms-listener>
         </listeners>
         <actions mep="OneWay">
          <action class="org.jboss.soa.esb.actions.SystemPrintln" name="println">
           <property name="message"/>
          </action>
          <action class="net.test.SaveDB" name="SaveDB"/>
          <action class="net.test.ThrowExpection" name="ThrowFault"/>
         </actions>
        </service>
      </services>
      </jbossesb>
      
      
      
      

       

       

       

      Now when send message to queue2_gw it get's delivered nicely into SaveDB action and data is saved into MySQL, next action throws RuntimeExpection, transaction is rolled back but message will never end up into DLQ. This causes infinite loop. Could someone help me and show how to use max-delivery-attemps property? I have tried to set it also into global hornet-configuration.xml but it doesnt change situtation at all.

       

      However changing <redelivery-delay>5000</redelivery-delay> has effect.


      It looks like that deliveryCount is not updated at all while debugging QueueImpl.java (HornetQ 2.1.2 Final) lines 965-973.

        int maxDeliveries = addressSettings.getMaxDeliveryAttempts();
      
      
            if (maxDeliveries > 0 && reference.getDeliveryCount() >= maxDeliveries)
            {
               sendToDeadLetterAddress(reference);
      
      
               return false;
            }
      

       

       

       

       

       

       

       

      BR,

      Marko