activemq-artemismessagebrokerdead-letter

ActiveMQ Artemis max-redelivery-delay and deadletterqueue


We are using the broker ActiveMQ Artemis 2.26.0, and I'm trying to set up a redelivery mechanism on a queue.

I would like for some messages to be retried for 72h maximum with progressive back-off. After 72h the message should be sent to a DLQ.

The doc states that both mechanisms of message redelivery and dead-letter queue can be combined, so I tried the following, using the examples provided with ActiveMQ Artemis:

broker.xml:

      <address-settings>
         <!--override the redelivery-delay  for the example queue-->
         <address-setting match="exampleQueue">
            <redelivery-delay>30000</redelivery-delay>
            <redelivery-delay-multiplier>2.5</redelivery-delay-multiplier>
            <dead-letter-address>deadLetterQueue</dead-letter-address>
            <max-redelivery-delay>259200000</max-redelivery-delay>
         </address-setting>
      </address-settings>

      <addresses>
         <address name="deadLetterQueue">
            <anycast>
               <queue name="deadLetterQueue"/>
            </anycast>
         </address>
         <address name="exampleQueue">
            <anycast>
               <queue name="exampleQueue"/>
            </anycast>
         </address>
      </addresses>

It seems that with this configuration the message are sent to deadLetterQueue after 10 redeliveries (default value of max-delivery-attempts).

How do I combine these values to fit my scenario?


Solution

  • TL; DR; you need to set a max-delivery-attempts value greater then 10

    The total delivery delay is a geometric series so it is <redelivery-delay>*(1-<redelivery-delay-multiplier>^<max-delivery-attempts>)/(1-<redelivery-delay-multiplier>)

    In your case the total delivery delay is 30000*(1-2.5^10)/(1-2.5)=190714863 that is less then 72h (259200000) so to fit your scenario you need to set a max-delivery-attempts value greater then 10, i.e. with max-delivery-attempts = 11 the total delivery delay is 476817158 (132h) that is greater than 72h.