Shashaank V V
Shashaank V V

Reputation: 740

Spring boot AMQP Concurrent listeners execute sequentially?

I have a Spring AMQP listener defined like this :-

@RabbitListener(queues = "spring-boot-durable", concurrency="10")
public void recieve(String message) {
   ....some code here
}

Now in rabbitmq management portal i am publishing 30 messages when the above service is down, and bringing the listener service up.

When i do this, the messages are executed sequentially (one by one) rather than parallelly (10 at a time) although i set the concurrency to 10 as shown in the above piece of code.

Any reason why this is happening and any fix for this?

Upvotes: 0

Views: 392

Answers (1)

Gary Russell
Gary Russell

Reputation: 174554

I believe you are affected by the prefetchCount - by default it's 250 so all the messages are going to one consumer.

Reduce it to distribute across the consumers but I recommend keeping it higher than 1; otherwise it will hurt performance.

Upvotes: 1

Related Questions