[rabbitmq-discuss] basic.Get and basic.Consume on the same queue

Greg gregory.sainson at gmail.com
Wed Mar 7 14:17:34 GMT 2012


Makes perfect sens.

Thx

On Wednesday, March 7, 2012 3:03:48 PM UTC+1, Marek Majkowski wrote:
>
> On Wed, Mar 7, 2012 at 13:52, Greg <gregory.sainson at gmail.com> wrote:
> > Hi,
> >
> > I can't find any info on the web about it.
> >
> > I currently have different programs that consumes the same queue.
> > One program is registered to the queue with a basic.Consume.
> > The other one is receiving messages with basic.Get. Unfortunately, It
> > doesn't get any messages, basic.Get always returns null, like the queue 
> is
> > empty.
> > If I change it with a basic.Consume, it works fine. I'm using the Java
> > client of RabbitMQ.
> >
> > Anyone has any idea with this happens?
>
> If you're using Basic.Consume without setting Basic.QOS, Rabbit
> sends a bulk of messages to the consumer. (in hundreds of messages).
>
> Assuming the consumer uses Acks, the messages are then slowly
> marked as Acknowledged and deleted.
>
> But in the meantime all the messages were already sent to the
> BasicConsume client - thus Basic.Get will find that there
> aren't any messages ready!
>
> The solution is to configure prefetch count using Basic.Qos
> and also you must use Acknowledgments. (Basic.Qos without
> acks makes no sense).
>
> When you change second consumer to use BasicConsume,
> it will hang and wait for mesages. Rabbit than sees:
> okay, there are two consumes waiting on that queue.
> When a new message arrives Rabbit will make a decision
> where to send the message. It will try to do something
> like round-robin. Thus - your second consumer will
> receive some messages (every second one in a perfect
> world).
>
> Hope that helps,
>  Marek
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20120307/6ba7f797/attachment.htm>


More information about the rabbitmq-discuss mailing list