How to limit rabbitmq's queue to wait for ack before send message to other channels

6/26/2021

I have an application that runs as multiple instances (pods on Kubernetes).

This application consumes messages from the queue with prefetch 1 and ack back after It finishes the process.

I have a function that must run from only one instance at a time. But the queue tries to send the next message to others instance consumers.

Is there anyways to block other consumers to not receive a message or block a queue to not send a message before ack?

Thanks you very much

-- LLF
.net
kubernetes
rabbitmq

1 Answer

6/28/2021

I've found the solution on the Rabbit MQ document now. I just need to put an argument "x-single-active-consumer" when declaring the queue.

https://www.rabbitmq.com/consumers.html#single-active-consumer

-- LLF
Source: StackOverflow