Rabbitmq concurrent consumers in Spring boot

2019-04-15 00:19发布

I'm using @RabbitListener annotation and SimpleRabbitListenerContainerFactory bean for parallel execution of rabbitmq messages and setting the min and max concurrent consumers in the following way :

@Bean
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory() {
    SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
    factory.setConnectionFactory(connectionFactory());
    factory.setConcurrentConsumers(MIN_RABBIT_CONCURRENT_CONSUMERS);
    factory.setMaxConcurrentConsumers(MAX_RABBIT_CONCURRENT_CONSUMERS);
    factory.setConsecutiveActiveTrigger(1);
    factory.setAcknowledgeMode(AcknowledgeMode.MANUAL);
    return factory;
}

The min limit is 3 and the max limit is 10. With this configuration, only 3 messages are getting executed parallelly, even though there are 12 messages in the queue.

Please tell me what is wrong with the config?

1条回答
做自己的国王
2楼-- · 2019-04-15 00:52

With the default configuration, a new consumer will be added every 10 seconds if the other consumers are still busy.

The algorithm (and properties to affect it) is described here.

查看更多
登录 后发表回答