jondot / sneakers

A fast background processing framework for Ruby and RabbitMQ
https://github.com/jondot/sneakers
MIT License
2.25k stars 332 forks source link

serial message processing #200

Open dan-corneanu opened 8 years ago

dan-corneanu commented 8 years ago

Hello, I have a queue that receives messages that have to be processed in the same order they have arrived and the next message can only be processed after the previous one (in the queue) has been processed.

Basically these means that I need to make sure that there is only one worker active at any time, processing messages from this queue.

How can I achieve this with sneakers?

RabbitMq support subscribing to a queue with an exclusive: flag set to true (the queue will not be exclusive, just the subscription is exclusive). This guarantees that only one consumer can access the queue at a given time.

Regards, Dan

michaelklishin commented 8 years ago

But it does not guarantee that the consumer won't be processing multiple deliveries in parallel. You need to set a prefetch value for your channel. See Tutorial 2 and Bunny docs on manual acknowledgements.

dan-corneanu commented 8 years ago

@michaelklishin you are right, I have to use prefetch: 1 and manual_ack: true

However, how can I make sure sneakers will not create multiple workers and subscribe them all to the queue?