[rabbitmq-discuss] How to do blocking asynchronously with Pika? I want 1 message at a time and stop receiving until I'm ready again.

Scott Chapman Scott.Chapman at servicenow.com
Thu Feb 21 18:11:15 GMT 2013


On 2/20/13 4:12 PM, "Matthias Radestock" <matthias at rabbitmq.com> wrote:

>Scott,
>
>On 20/02/13 23:27, Scott Chapman wrote:
>> After further exploring it appears that you do this:
>> Using the BlockingConnection:
>> Receive Message
>> Run Handler to process message which can immediately ACK the message.
>> When Handler returns, next message is received from RabbitMQ.
>>
>> Simpler!
>
>The above won't stop rabbit from sending one or more messages to the
>client (depending on the basic.qos prefetch setting). While the app
>won't get to the see these messages until the Handler returns, the
>messages will still take up buffer space at the client or in the
>network, and they will be unavailable to other consumers on the same
>queue.
>
>If that is not what you want then follow Michael's suggestion of
>cancelling the subscription. Or simply delay the ack until the app is
>ready to process the next message.

Mathias

I'd like to clarify some points here.

If 1st message arrives, I ack it, and I am processing it then 2nd message
arrives, it will be held _in_the_client_?
So if the client gets rebooted, the message will be lost?
It appears that I can set the basic.qos prefetch-count to zero to solve
this problem?

If I decide to cancel the consumer,  I assume the proper order of events
would be:

Enable Consumer
Receive message 1
Cancel Consumer
Ack Message
Process Message
-> back to Enable Consumer.

I think one would not want to ACK the message before canceling the
consumer because it might immediately dump another message into the
consumer?

Thanks for the tips,

Scott



More information about the rabbitmq-discuss mailing list