RabbitMQ and message priority

Kelly picture Kelly · May 24, 2012 · Viewed 37.9k times · Source

Does RabbitMQ have any concept of message priority? I have an issue were some more important messages are being slowed down due to less important messages sitting before it in the queue. I would love the high-priority ones to take precedence and move to the front of the queue.

I know I can approximate this using two queues a "fast" queue and a "slow" queue, but that seems like a hack.

Does anyone know of a better solution using RabbitMQ?

Answer

womble picture womble · Mar 16, 2015

The answers on this question are out-of-date. As of RabbitMQ 3.5.0, there is now in-core support for AMQP standard per-message priorities. The documentation has all the gory details, but in short:

  • You need to define the queue's priority range at the time the queue is created;
  • Messages without a priority set get a priority of 0;
  • Messages with a numeric priority higher than the maximum set on the queue get the highest priority the queue supports.

More interesting caveats are in the docs. It's well worth reading them.