Search code examples
node.jsrabbitmqamqpmessage

RabbitMQ receive messages sequentially after ACK


I am looking to get the following pattern to receive messages "sequentially" with RabbitMQ. I use Node.js framework as consumer.

Lets say there are 3 messages in the queue, I need this pattern:

receive msg#1 -> process -> send ACK -> receive msg#2 -> process -> send ACK receive msg#3 -> process -> send ACK

But what's happening is node.js consumer receives all 3 messages in parallel and RabbitMQ waits for the individual ACK back to remove the messages off the queue. This is not sequential.

My queue is durable, ACK required. Is there something I am missing?

Please help!


Solution

  • Found the answer. I had to set the prefetch count. In the above scenario had to set prefetch to 1.