I have a requirement where I have 1 direct exchange and 5 different queues bind to it with unique routing key. Basically the each queue is meant for different consumer endpoints. I am using the spring managed endpoint registry using the @RabbitListener
. So there are 5 endpoints registered. While I was implementing it I have created a single RabbitListenerContainerFactory
with a concurrentConsumer
value as 2. But I have a question on this, if there is a single factory created with consumer size as 2 then will all the endpoint will have separate consumers or the consumers are created per factory and this containerFactory
will serve all the 5 endpoints. So if the 2 consumer serves all the 5 queues will there won't be a unbalancing in load where the other queue consumers will be idle until one queue messages is served first?
Should I create separate containerFactory
for different endpoints?
Each @RabbitListener
gets its own container, each with 2 consumers.
It's a container factory that is used to create a container for each annotated method. Consider it to be like a "template"; much like the <rabbit:listener-container/>
element in XML - it has a set of common properties, but each <rabbit:listener/>
child element gets its own container.