[rabbitmq-discuss] Problem with multiple consumers on multiple servers !

Tim Watson tim at rabbitmq.com
Mon Apr 1 13:42:59 BST 2013


tluck,

On 1 Apr 2013, at 10:16, tluck wrote:

> The real problem seems is the working fashion of rabbitmq (round robin). If
> there are 2 consumers on a queue then I should see 2 unacknowledged messages
> at a time (meaning, 2 consumers are consuming messages).

No that is just not correct, or at the very least you're phrasing it in a way
that doesn't make any sense to me. Are you saying that you want a per-queue (rather
than per-consumer) prefetch count?

> But, I see only 1
> unacknowledged message even there are plenty of messages in queue waiting to
> be consumed.

You 'see only 1 unacknowledged message' where? In one consumer, or across all
consumers, or what!? How are you determining this - are you using the management console?

* How many consumers connected to the one queue?
* What prefetch setting (if any) for each consumer? Is it set to '1' per-chance?

> If both the consumers are running on different threads then how
> could this possible ? why only 1 consumer is consuming message and other one
> is in idle state ? 

Do you have the prefetch count set explicitly (or does your client library do this)? It appears
that you do:

"$channel->basic_qos(null, 1, null);"

This tells rabbit not to give that consumer more than 1 un-acked message at a time. Where are
these other consumers getting created? If they're on a separate connection (and machine) then
can you see them in the management console?

> 
> Is there any other way by which I can make consumers to consume next
> messages from the queue as soon as they finish their last job/message ?  
> 

What? That's what happens as soon as they send an ACK - are you forgetting to ACK or something?
Perhaps someone who understands the PHP client better than I do can comment on what might be
going on here, because this just doesn't make any sense to me. Are these second consumers by
any chance running in the same PHP application? Isn't PHP single threaded? Could that be why your
application isn't progressing the way you'd expect it to?



More information about the rabbitmq-discuss mailing list