Spring Boot中的Rabbitmq并发使用者 [英] Rabbitmq concurrent consumers in Spring boot
问题描述
我正在使用@RabbitListener批注和SimpleRabbitListenerContainerFactory bean来并行执行Rabbitmq消息,并通过以下方式设置最小和最大并发使用者:
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;
}
最小限制为3,最大限制为10.使用此配置,即使队列中有12条消息,也只能并行执行3条消息.
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?
推荐答案
使用默认配置,如果其他使用者仍很忙,则每10秒将添加一个新使用者.
With the default configuration, a new consumer will be added every 10 seconds if the other consumers are still busy.
这篇关于Spring Boot中的Rabbitmq并发使用者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!