1

I would like to use the node-amqp library the create multiple consumers for RabbitMQ, but I can't understand whether the prefetch-count option refers to count per consumer or not. I would like each consumer to have its own prefetch count that does not depend on other consumers.

Thanks.

Mister_L
  • 2,469
  • 6
  • 30
  • 64
  • 2
    FWIW - you shouldn't use node-amqp. that library has a number of known memory leaks and bugs that will cause serious problems. the RabbitMQ team recommends "amqplib" (aka amqp.node) instead: https://github.com/squaremo/amqp.node – Derick Bailey Aug 18 '16 at 14:57

1 Answers1

2

Can be per single consumer but can be set for multiple consumers at once. Just look for title Example - single consumer here. So AMQP supports it. I'm not sure for the library you've mentioned but on official java lib it is like that - transparent towards AMQP's basic.qos method. Also from the aforementioned link

Note that the default value for the global flag is false in most APIs

and for rabbitmq when global==false

prefetch_count is applied separately to each new consumer on the channel

so you would need to find out how it's implemented in that librabry.

Additionaly consider using amqp.node library, since this one is used on rabbimtq tutorials. (EDIT I only now see that Derick Bailey has mentioned that already.)

cantSleepNow
  • 9,691
  • 5
  • 31
  • 42
  • 1
    i think the default for rabbitmq is not to be global, so the prefetch will be set per channel. because of this, you should limit your consumers to a single queue per channel when using this setting – Derick Bailey Aug 18 '16 at 15:01
  • Yes, that's what I also understood from the docs. And I also agree - 1 channel, 1 consumer, 1 queue. I didn't stumble upon a use case where otherwise would be better still, and it makes most sense anyhow. – cantSleepNow Aug 18 '16 at 15:04
  • @DerickBailey looking here, https://www.rabbitmq.com/consumer-prefetch.html , it seems that multiple consumers get their own prefetch count when global is set to False (which is the default). Could this have been added in a new edition of Rabbit (this post was two years ago) or am I misinterpreting this? – UCProgrammer Oct 12 '18 at 18:38