[rabbitmq-discuss] asynchronous fetching messages from rabbitMQ queues
matthias at rabbitmq.com
Thu Nov 10 09:07:17 GMT 2011
On 10/11/11 08:51, pavuuu wrote:
>> When using 'BasicConsume' without setting BasicQos on channel, it seems it
>> is connecting to RabbitMQ everytime I call 'consumer.Queue.Dequeue()'.
Dequeue *never* triggers an interaction with the server. Messages are
sent by the server to the client (and buffered in the consumer.Queue) in
the background. Basic.Qos controls the flow of these messages. Without a
prefetch limit, the server sends messages to the client as soon as they
become available in the queue. With a prefetch limit of N, the server
will send at most N message and then send no more until it receives one
or more acks.
>>>> Btw, you do realise that the Dequeue() operation is client-side only,
>>>> right? i.e. it is simply manipulating a client side buffer which is
>>>> filled as and when the client receives a message from the server.
>> yes, I understood that. When I set the prefetch to 1000, at client side a
>> buffer is being maintained which will contain a maximum of 1000 messages.
>> When I call dequeue, it is giving me the message from this buffer.
The buffer is there regardless of Basic.Qos. But without Basic.Qos it
can grow unbounded if the client app isn't draining it fast enough. With
Basic.Qos the size is bounded to the prefetch size.
>> And if there are less than 1000 messages in buffer, it refills the buffer
>> if there are any messages in the queue bound to it.
The refilling is triggered by the client ack'ing messages.
More information about the rabbitmq-discuss