Priority queue not working: when there are comsumers that are consuming

120 views
Skip to first unread message

Empty Empty

unread,
Feb 3, 2020, 2:53:41 AM2/3/20
to rabbitmq-users
Hello! I've set max priority for my queue, but messages are delivered in order they arrived.

my mq version: 3.7.9

Description: The priority is work when there are no consumers(That is, send the message and then start the consumer, the priority is work). But there are comsumers that is comsuming, the priority is not work, messages are delivered in order they arrived.


iwe...@mail.de

unread,
Feb 3, 2020, 3:45:53 AM2/3/20
to rabbitm...@googlegroups.com
I don’t think priority should work in a stream like system. You don’t know during what time piece the priority should work. For static pool max priority could make the message ahead of any others. Just my thoughts, maybe not correct.

Regards
Wesley Peng

> --
> You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/91e2e202-7200-46db-a6cb-d9c7f9a6a072%40googlegroups.com.
>

Empty Empty

unread,
Feb 3, 2020, 4:29:09 AM2/3/20
to rabbitmq-users
Sorry, I don't understand, for "For static pool max priority could make the message ahead of any others.", Can you explain it to me?

在 2020年2月3日星期一 UTC+8下午4:45:53,postm...@wsly.de写道:
I don’t think priority should work in a stream like system. You don’t know during what time piece the priority should work. For static pool max priority could make the message ahead of any others. Just my thoughts, maybe not correct.

Regards
Wesley Peng

> On Feb 3, 2020 - 3:53 PM, emptydr...@gmail.com wrote:
>
>
> Hello! I've set max priority for my queue, but messages are delivered in order they arrived.
>
> my mq version: 3.7.9
>
> Description: The priority is work when there are no consumers(That is, send the message and then start the consumer, the priority is work). But there are comsumers that is comsuming, the priority is not work, messages are delivered in order they arrived.
>
> I test with script (based on  https://gist.github.com/michaelklishin/ec056aade6ba764a27cb1ba8ca187a42) given in (https://groups.google.com/forum/#!msg/rabbitmq-users/qJ_XIUfjJUM/6Z5XfkPrEQAJ)
>
> The script I actually use is : https://github.com/emptyknowledge/temporary/blob/master/rabbitmq_priority_not_work/priority.py
> The running result is : https://github.com/emptyknowledge/temporary/blob/master/rabbitmq_priority_not_work/run_result.png
>
> --
> You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.

> To unsubscribe from this group and stop receiving emails from it, send an email to rabbitm...@googlegroups.com.

Karl Nilsson

unread,
Feb 3, 2020, 8:00:10 AM2/3/20
to rabbitm...@googlegroups.com
Prioritisation will only be applied when messages need to be queued (i.e. they show up as "ready messages"). If a message arrives at the queue and can immediately be delivered to a consumer then it will, irrespective of it's priority. Given it is then the only known message on the queue apart from those currently being processed by consumers this is ok.

Try your test again with lower consumer prefetch (QoS) so that messages have to wait to be delivered. 


Cheers
Karl

To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/2b98086e-9e80-4ff8-9c21-18722a88bd57%40googlegroups.com.


--
Karl Nilsson

Pivotal/RabbitMQ

Empty Empty

unread,
Feb 3, 2020, 10:17:49 PM2/3/20
to rabbitmq-users
I test agin with add code "ch.basic_qos(prefetch_count=1)", the run result is same. (my pika version is 1.1.0 )  
There are codes ("time.sleep(1)")  in consumer_callback method,so the messages are queued. (send messages needing little time but somsuming is slow).

The new scripts(priority_server.py, priority_client.py) is in https://github.com/emptyknowledge/temporary/tree/master/rabbitmq_priority_not_work/add_basic_qos
.
在 2020年2月3日星期一 UTC+8下午9:00:10,Karl Nilsson写道:


--
Karl Nilsson

Pivotal/RabbitMQ

Wyatt Chun

unread,
Feb 3, 2020, 11:28:32 PM2/3/20
to rabbitm...@googlegroups.com
May due to time window issues.
If you want to test, give another try on prefetch=10 and sleep(10). You must have consuming slower than publishing.

Regards 

To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/65480d84-ea28-4d56-b6ea-14e15041cc47%40googlegroups.com.

Empty Empty

unread,
Feb 4, 2020, 1:08:42 AM2/4/20
to rabbitmq-users
I test as you say, but priority still doesn't work.

Regards

在 2020年2月4日星期二 UTC+8下午12:28:32,Wyatt Chun写道:

Michael Klishin

unread,
Feb 5, 2020, 4:41:06 PM2/5/20
to rabbitmq-users
We cannot suggest anything without an executable example that demonstrates the issue.
You are asking for free support on this list, please help others help you by providing relevant information.

On an unrelated note, RabbitMQ 3.7.9 is 14 releases behind even in the 3.7.x branch.

To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/f298f318-c68f-4abc-9b76-44793bdae420%40googlegroups.com.


--
MK

Staff Software Engineer, Pivotal/RabbitMQ

Empty Empty

unread,
Feb 16, 2020, 10:16:56 PM2/16/20
to rabbitmq-users
Sorry, I haven't come to the discussion group for many days, The problem is in our side, The reason is that two lines of code are written in reverse order: `ch.basic_qos(prefetch_count=1)`, `
ch.basic_consume(callback, q, no_ack=False, arguments={"x-priority": 10})`

Not working code:
```
ch.basic_consume(callback, q, no_ack=False, arguments={"x-priority": 10})
ch.basic_qos(prefetch_count=1)
ch.start_consuming()
```


Working code:
```
ch.basic_qos(prefetch_count=1)
ch.basic_consume(callback, q, no_ack=False, arguments={"x-priority": 10})
ch.start_consuming()
```

Thank you for your reply!

Regards!

在 2020年2月6日星期四 UTC+8上午5:41:06,Michael Klishin写道:

Michael Klishin

unread,
Feb 17, 2020, 7:23:18 AM2/17/20
to rabbitmq-users
Thank you for reporting back to the list. To clarify, the effects of those lines is that a consumer was added before
channel prefetch was set to 1, meaning that all deliveries have gone directly to the consumer and were not prioritised
(per the documented priority queue design choice).

It is actually possible to change prefetch for already added consumers [1] but it's a little known feature that
you don't need most of the time, and it won't make reasoning about the code easier anyway.


To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/86deb1c7-1025-4db8-b1f2-730252bad1f4%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages