Erlang Mailing Lists

Author Message

<  RabbitMQ mailing list  ~  AMQP ack with multiple subscribers

Guest
Posted: Thu Oct 15, 2009 12:29 am Reply with quote
Guest
If I have a queue with multiple subscribers/consumers and it also requires acks for the messages, what is the resulting behavior?

Will the queue round robin the messages out to the subscribers regardless of whether the messages have been ack'ed yet or not? Or will the first message basically stall the delivery of the other messages in the queue until the first message has been ack'ed?

Thanks!

Post received from mailinglist
Guest
Posted: Thu Oct 15, 2009 10:15 am Reply with quote
Guest
On Thu, Oct 15, 2009 at 01:28, Colin Z <theczintheroc2007@gmail.com> wrote:
> If I have a queue with multiple subscribers/consumers and it also requires
> acks for the messages, what is the resulting behavior?
>
> Will the queue round robin the messages out to the subscribers regardless of
> whether the messages have been ack'ed yet or not? Or will the first message
> basically stall the delivery of the other messages in the queue until the
> first message has been ack'ed?

By default, if you have two consumers that are reading from one
queue, they will receive exactly every second message. No matter
if the messages were "light" or "heavy". For example, if queue looks like:
[light, heavy, light, heavy, light, heavy]
The first consumer will get all the "light" messages, and the second
one will get all the "heavy" ones. No matter when they will be acknowledged.
See this code:
http://ai.pjwstk.edu.pl/~majek/dump/qos_no.py


Basic.qos is used to fight this limitation. Using it you can specify
how many messages are allowed to be unacknowledged for a channel.
Here you can see how to use it:
http://ai.pjwstk.edu.pl/~majek/dump/qos_yes.py

Cheers!
Marek Majkowski

_______________________________________________
rabbitmq-discuss mailing list
rabbitmq-discuss@lists.rabbitmq.com
http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Post received from mailinglist
tonyg
Posted: Thu Oct 15, 2009 10:25 am Reply with quote
User Joined: 07 Nov 2006 Posts: 199
Colin Z wrote:
> Will the queue round robin the messages out to the subscribers
> regardless of whether the messages have been ack'ed yet or not?

Yes, as best it can, up to each subscriber's basic.qos and TCP buffer
limitations.

Acking only affects flow of messages when basic.qos is in effect.

Regards,
Tony


_______________________________________________
rabbitmq-discuss mailing list
rabbitmq-discuss@lists.rabbitmq.com
http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Post received from mailinglist
View user's profile Send private message MSN Messenger
Guest
Posted: Thu Oct 15, 2009 2:19 pm Reply with quote
Guest
Thanks Marek and Tony,

Sorry to belabor the question, but I just want to make sure I understand.

Say I have Consumers A and B subscribed to queue Q which has 10 messages in it.

"A" would get message 1 and let's say it takes 10 seconds to process before it ACKs. At what time would "B" get message 2: immediately, or after 10 seconds?


On Thu, Oct 15, 2009 at 6:15 AM, majek04 <majek04@gmail.com (majek04@gmail.com)> wrote:
Quote:

On Thu, Oct 15, 2009 at 01:28, Colin Z <theczintheroc2007@gmail.com (theczintheroc2007@gmail.com)> wrote:
> If I have a queue with multiple subscribers/consumers and it also requires
> acks for the messages, what is the resulting behavior?
>
> Will the queue round robin the messages out to the subscribers regardless of
> whether the messages have been ack'ed yet or not? Or will the first message
> basically stall the delivery of the other messages in the queue until the
> first message has been ack'ed?



By default, if you have two consumers that are reading from one
queue, they will receive exactly every second message. No matter
if the messages were "light" or "heavy". For example, if queue looks like:
[light, heavy, light, heavy, light, heavy]
The first consumer will get all the "light" messages, and the second
one will get all the "heavy" ones. No matter when they will be acknowledged.
See this code:
http://ai.pjwstk.edu.pl/~majek/dump/qos_no.py


Basic.qos is used to fight this limitation. Using it you can specify
how many messages are allowed to be unacknowledged for a channel.
Here you can see how to use it:
http://ai.pjwstk.edu.pl/~majek/dump/qos_yes.py

Cheers!
tonyg
Posted: Thu Oct 15, 2009 2:41 pm Reply with quote
User Joined: 07 Nov 2006 Posts: 199
Colin Z wrote:
> "A" would get message 1 and let's say it takes 10 seconds to process
> before it ACKs. At what time would "B" get message 2: immediately, or
> after 10 seconds?

Immediately.

Regards,
Tony


_______________________________________________
rabbitmq-discuss mailing list
rabbitmq-discuss@lists.rabbitmq.com
http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Post received from mailinglist
View user's profile Send private message MSN Messenger
jpecci
Posted: Tue Oct 20, 2009 12:42 pm Reply with quote
Joined: 20 Oct 2009 Posts: 1
Marek your code is very clear thanks! I still have a question.
What happens if I do not acknowledge a message when no_ack=False?
In your code, say both 1st and 2nd have set no_ack=False but only 1st acknowledges. After 2nd receives the first message it hangs up. I was expecting the unacknowledged message to reappear in the queue either resubmitted to “1st” or to “2nd” but actually it never comes back (at least not in the following 4 minutes).
Do you have any idea? Would you know how to set a timeout to make the message reappear in the queue if not acknowledged let’s say after few seconds?!

Thanks,
Jacopo
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum