[rabbitmq-discuss] best practice for "work queue" type application

Ask Solem ask at rabbitmq.com
Wed Nov 7 18:44:57 GMT 2012


On 4 Nov 2012, at 18:12, John Cartwright <john.c.cartwright at noaa.gov> wrote:

> 
> I'm not quite clear however on the point at which the worker consumes
> the next message in the queue.  Assuming I'm using
> "channel.start_consuming()" as in the tutorial and my worker acks the
> message as soon as it receives it, won't it try to consume a second
> message and the single worker will end up concurrently processing two
> jobs?
> 


Hey John,

Short answer: No!

Python isn't implicitly parallel so for it to consume messages and
process them at the same time you would have to start multiple (OS) threads
reading from the same socket.  This wouldn't work well since connections
aren't thread safe.

If you are using an asynchronous event loop then the next message
will be consumed when control is given back to the loop
so that it reads from the socket again.

Similarly, when used synchronously the next message will
be consumed when you call 'connection.drain_events()' again
after processing the message.



More information about the rabbitmq-discuss mailing list