arobson / rabbot

Deprecated: Please see https://github.com/Foo-Foo-MQ/foo-foo-mq
MIT License
277 stars 129 forks source link

consume one semantics #126

Closed alonisser closed 6 years ago

alonisser commented 6 years ago

I'm searching where I can configure rabbot to consume "only one" message at a time, and don't start to handle another one until acked/rejected. I saw the "limit" parameter on a queue which If I understand correctly channel prefetch limit, but I'm not sure this is what I'm searching for, failed to understand that from the docs

I'm open to implementing but I need a direction to where would be the correct place. Or to write clearer docs about that if this option is available

Thanks!

alonisser commented 6 years ago

Seems that what I need is a "hatch" to channel.basicQos

arobson commented 6 years ago

@alonisser - the prefetch limit is what you want to use. You'll need to make sure you haven't turned acknowledgements on the queue off (they're on by default).

Just be aware that setting the prefetch to 1 will have real, notable performance impact. Maybe that's exactly what you want, but I just want to let you know in advance :)

If you explain more of your use case and what you're trying to accomplish, I may be able to suggest alternative approaches if the speed impact is too much of an issue.

alonisser commented 6 years ago

Thanks, I suspect so, My use case:

I need the app not to process multiple events in the same time, because:

  1. If an event crashes the app I need to happen only on a specific event, so I can remove it easily from the queue not on a random event I don't know which. I could solve that perhaps with an inner task queue in my app, processing each message sequance. But it's more code to write and the other reason ..
  2. Event order might have a meaning, so on multiple consumer scenario (with competing consumers) as long as each takes one, I keep the order (although they might be a race condition even then, on save) but if one prefetches let's say 10 events, and the other the remaining 1 , and event 2 and 11 have an order then I'll probably going to break the order

I know reason 2 is complicated to achieve correctly with multiple competing consumers, So any other suggestions for the first case?

Thanks for the help

alonisser commented 6 years ago

Thanks. I'll close this issue for now