3

How do i set the prefetch count to one for amqplib in nodejs? link to Lib on git

The desired result is that the consumer is only taking one message from the queue process it and when done take a new message. I have a setup where some messages takes long time to process and others take very short time. Hence i do not just want to share the messages equally on all consumers.

Peter Savnik
  • 763
  • 1
  • 8
  • 27

2 Answers2

8

I used ch.prefetch(1); after asserting the queue with a task and before binding the queue to an exchange.

Peter Savnik
  • 763
  • 1
  • 8
  • 27
0
channel.prefetch(1);

You can view the docs here for reference

ShnAlmighty
  • 1
  • 1
  • 1