[rabbitmq-discuss] How to do blocking asynchronously with Pika? I want 1 message at a time and stop receiving until I'm ready again.
Tim Watson
tim at rabbitmq.com
Wed Feb 20 23:32:50 GMT 2013
On 20 Feb 2013, at 20:50, Scott Chapman wrote:
> What's the best practice to make it so I receive a message in a single-threaded app, process it and don't get any more messages until I'm ready again?
>
I would consider using basic.get with noAck=false for this. The basic.get method offers a pull-API, where the client asks the broker for a message and the broker replies with either a message (in a basic.get-ok) or a basic.empty indicating the queue contains no messages.
https://pika.readthedocs.org/en/latest/examples/blocking_basic_get.html
> Something like:
>
> Receive Message
> Turn off Channel – how best to do this?
> Ack Message
> Process Message
> Turn on Channel
This seems like a lot of work to replicate what basic.get offers ootb. Is there a compelling reason not to use basic.get for your purposes?
Cheers,
Tim
More information about the rabbitmq-discuss
mailing list