0
votes

If I have the following configuration to listen queue1,queue2,queue3, if all queues have messsage, what's the order of message consumes? first consume all of queue1 or in round robin fashion?

  <rabbit:listener-container id="connectListenerContainer" connection-factory="connectionFactory" prefetch="1" concurrency="1">
        <rabbit:listener ref="keyRequestListener" queues="queue1,queue2,queue3" />
    </rabbit:listener-container>
1

1 Answers

1
votes

If you listen to the several queue and all of them have messages, they are consumed queue by queue: the queue2 ins't consumed until queue1 has messages and so on.

We use this technique to implement priority pattern, where queue1 represents the highest priority.

However there is some undesired side-effect, when we consume queue3, but a message apprears in queue1. We don't see that message until queue3 won't be drained.

To confirm that the piece of source code BlockingQueueConsumer:

for (String queueName : queues) {
    if (!this.missingQueues.contains(queueName)) {
        consumeFromQueue(queueName);
    }
}