Help Center/ Distributed Message Service for RabbitMQ/ User Guide/ Configuring Virtual Hosts/ Managing RabbitMQ Queues/ Configuring a RabbitMQ Priority Queue
Updated on 2025-12-30 GMT+08:00
Configuring a RabbitMQ Priority Queue
A priority queue is a special queue structure compared with the conventional first in first out (FIFO) rule. It features message consumption in priority-based order.
Priority queues are available in RabbitMQ 3.x.x and AMQP-0-9-1.
Notes and Constraints
- In RabbitMQ 3.x.x, the priority value range is 0 to 255.
- In RabbitMQ AMQP-0-9-1, the priority value range is 0 to 9.
Configuring a Priority Queue
- In queue declaration, set the x-max-priority parameter (for example, x-max-priority = 5). This parameter specifies the maximum priority supported by a queue. A larger value indicates a higher priority.
- In message sending, the priority attribute specifies the priority. A larger value indicates a higher priority.
- (Optional) Divide the queue into multiple sub-queues. Messages are processed in descending order of priority. Sample code:
String queueName = "queue" channel.queueDeclare(queueName, true, false, false, args); final AMQP.BasicProperties.Builder basicProps = new AMQP.BasicProperties().builder(); basicProps.priority(5); channel.basicPublish("", queueName, basicProps.build(), "test".getBytes())
Parent topic: Managing RabbitMQ Queues
What is your overall rating for this page?
0
1
2
3
4
5
6
7
8
9
10
Very dissatisfiedVery satisfied
Thank you very much for your feedback. We will continue working to improve the documentation.
The system is busy. Please try again later.