Search code examples
rabbitmqpriority-queue

Specific question about AMQP priority queues in RabbitMQ


There is a specific detail about priority queues that I can't find a definitive answer on. RabbitMQ documentation states that:

  • A priority queue is created by using x-max-priority, and recommends setting the value between 1 and 5 (or 1 and 10 in some places).
  • Messages with higher priority are delivered first.
  • A message with a priority value higher than x-max-priority for the queue is capped at the value x-max-priority.
  • A message with no priority value is given a value of 0.

If I create a queue with, for example, x-max-priority of 3, does this mean that I actually have four priority levels (0 through 3), which also assumes that 0 is the lowest priority? What about a x-max-priority of 1--does that give me two priority levels (0 and 1)?


Solution

  • Yes. My understanding is that it's a zero-based numbering system. Messages sent without a priority key are assigned priority: 0, which is the lowest priority level.

    If I create a queue with, for example, x-max-priority of 3, does this mean that I actually have four priority levels (0 through 3), which also assumes that 0 is the lowest priority?

    Correct.

    What about a x-max-priority of 1--does that give me two priority levels (0 and 1)?

    Correct.