Distributed Semaphore and Fairness

79 views
Skip to first unread message

shivam fialok

unread,
Feb 22, 2022, 9:15:20 AM2/22/22
to rabbitmq-users
Hi,

I needed to implement distributed semaphore in one of the applications and I found this rabbitmq blog which describes a way of how this can be implemented using rabbitmq.
But I am concerned regarding the fairness.
So, when we have multiple consumers bound to the same queue, rabbitmq dispatches messages to them in round-robin order. But does rabbitmq gurantee that when new consumers join a queue, then any existing consumers which had already been waiting for a message (or resource) (they are waiting because a resource/message is not yet available) will get the message first (whenever the resource/message becomes available) before any new consumers? In simpler terms, does rabbitmq take into account how long a consumer has been waiting to decide which consumer gets the next message?

Let me know if something is unclear in the question.

Thanks in advance.

Wes Peng

unread,
Feb 22, 2022, 9:20:04 AM2/22/22
to rabbitm...@googlegroups.com
No, the round robin policy can’t promise that.
A new consumer has the same chance to get messages as the older ones.

Thanks 

--
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/0b7363c9-c1c7-4610-bf80-9e62b76b952dn%40googlegroups.com.

shivam fialok

unread,
Feb 22, 2022, 9:43:12 AM2/22/22
to rabbitmq-users

Okay. Thanks for the quick response.

Is there a way to achieve this kind of fairness in rabbitmq?
By the way, I tried the above using rabbitmq and it seems to make sure that older consumers get the message first. But I cound not find it in the documentation anywhere. I guess it is because the round robin policy does not gurantee that it will remain the case always.
Reply all
Reply to author
Forward
0 new messages