jondot / sneakers

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

[WIP] Add option for making consumer exclusive #388

Open anderslemke opened 5 years ago

anderslemke commented 5 years ago

In some situations, the execution order of messages is crucial. In such situations, RabbitMQ can ensure that there are no more than one consumers on a queue, with the exclusive option.

michaelklishin commented 5 years ago

This does not make the consumer exclusive, it makes the queue exclusive. Is that what you are really after?

anderslemke commented 5 years ago

@michaelklishin I might confuse some concepts here.

There is an exclusive flag in this gem already: https://github.com/jondot/sneakers/blob/7c059d1490e4dde43f98b801c38e4e0df7ac458c/lib/sneakers/configuration.rb#L20 As far as I understand, this controls the queue: https://www.rabbitmq.com/queues.html#exclusive-queues . This is what I would call "exclusive queue".

I want this PR to control the exclusive-flag in https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.consume . This is what I refer to when I say "exclusive consumer".

I will beef up the PR-description to talk about the motivation for this.

anderslemke commented 5 years ago

@michaelklishin I've tested this PR locally, and I get the following results.

When I set the new exclusive-flag to false, I get consumers with this config:

Screenshot 2019-03-20 at 10 13 50

When I set the new exclusive-flag to true, I get a consumer with this config:

Screenshot 2019-03-20 at 10 13 32

This is actually what I want to achieve. But I'm not sure I use the terms correct, though.