How to implement priority queues in RabbitMQ / pika

I am looking for an implementation of a priority queue using RabbitMQ. The mailing list recommends using multiple queues, each of which represents a different priority level.

My question is: how did you interrogate several queues in some priority order using pika (or maybe some other python library)?

+5
source share
3 answers

I don’t think there is a way to do this naively at the consumer level using pika, since by default all consumers have the same priority.

, , , . , , , , .

.

+3

. rabbitmq 3.5.0 :

RabbitMQ 3.5.0. .

It is also available withpika 1.1.0

Class pika.spec.BasicProperties (content_type = No, content_encoding = No, headers = No, delivery_mode = No, priority = No, correlation_id = No, reply_to = No, expiration = No, message_id = No, timestamp = No, type = No, user_id = No, app_id = No, cluster_id = No)

Code using this function might look like this:

channel.basic_publish(properties=pika.BasicProperties(priority=your_priority),
                      exchange=...,
                      routing_key=...,
                      body=...)
0
source

All Articles