Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set prefetch count to 1 for amqplib for nodejs

Tags:

node-amqp

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.

like image 412
Peter Savnik Avatar asked Oct 23 '25 15:10

Peter Savnik


1 Answers

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

like image 146
Peter Savnik Avatar answered Oct 26 '25 23:10

Peter Savnik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!