Help Center/
Distributed Message Service for RabbitMQ/
User Guide/
Configuring Virtual Hosts/
Managing RabbitMQ Queues/
Configuring a RabbitMQ Priority Queue
Updated on 2025-11-20 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())
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot