I have 4 instances of my spring boot app running on 4 different JVMs. Is there a way to set maximum global consumers? Currently I have setMaxConcurrentConsumers(1); set. The problem is that there is one consumer being created on each JVM. I was hoping to have one consumer created across the 4 JVMs. I am currently using SimpleRabbitListenerContainerFactory and was hoping that this feature is available there. If not is this possible with DirectRabbitListenerContainerFactory?
Basically I think I am asking how to set channel.basicQos(15, true); // Per channel limit in Spring-AMQP for RabbitMQ.
Thanks, Brian
There is no way to set such a limit if that limit is greater than 1.
To limit to a single consumer you can set the consumer's exclusive flag (on the @RabbitListener
); then only one consumer is allowed and the other instances will keep trying to consume until the current consumer dies (warm standby).