'RabbitMQ - Diff between 'delivery-limit' and 'x-delivery-limit' queue arguments

What is the difference between delivery-limit and x-delivery-limit?

When I set the x-delivery-limit as RabbitMQ queue argument I can see it is limiting my message requeue attempts, as I expected, but in the official RabbitMQ documentation I see the usage of delivery-limit.



Solution 1:[1]

Both are valid settings.

The difference is that delivery-limit is a policy vs x-delivery-limit is a queue argument.

The same difference applies to other RabbitMQ settings, for example

  • dead-letter-exchange is a policy vs x-dead-letter-exchange is a queue argument
  • queue-length is a policy vs x-queue-length is a queue argument

A queue argument is prefixed by x- and is also referred to as an x-argument. The x stands for "extra" or "extended" because these arguments extend the mandatory queue settings. Mandatory queue settings are for example the durable and exclusive properties. x-arguments are optional queue settings. x-arguments are set by clients when they declare a queue.

That is, to change an x-argument, you would need to re-deploy the client, and re-declare the queue. For an existing queue, changing an x-argument is not allowed and will result in an inequivalent arg error closing the channel.

This is where policies come in handy. They have the following benefits:

  1. Policies are applied dynamically. Once a queue is declared, policies can change queue settings at run time. Note that not all queue settings can be changed by a policy. For example changing the x-queue-type (for example from classic queue to quorum queue) is not allowed since a queue process and how it stores messages cannot just be changed dynamically once it has been created. However, most queue settings (including delivery-limit) can be changed dynamically via a policy.
  2. Policies can be applied to groups of queues (and groups of exchanges). A queue argument can only be applied to a single queue.

In general, it's good practice to use a policy instead of queue argument where possible because policies are more flexible.

More in the official docs: https://www.rabbitmq.com/parameters.html#why-policies-exist

Solution 2:[2]

I believe that delivery-limit is just name for header value x-delivery-limit. You can find in RabbitMQ UI for queue arguments.

There is a blog post from RabbitMQ with screenshots (Fig 9. Quorum queue arguments) where they are using x-delivery-limit header which works only with quorum queues (feature matrix)

UPD: in according with this screenshot x-delivery-limit is a part of queue features however delivery-limit is a part of policy definition applied to this queue. Check this article for more details.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ansd
Solution 2