@Configuration
public class RabbitmqConfig {
@Value("${spring.rabbitmq.concurrency}")
private Integer concurrency;
@Bean("containerFactory")
public SimpleRabbitListenerContainerFactory containerFactory(SimpleRabbitListenerContainerFactoryConfigurer configurer, ConnectionFactory connectionFactory){
SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
//设置线程数
factory.setConcurrentConsumers(concurrency);
//设置最大线程数
factory.setMaxConcurrentConsumers(concurrency);
configurer.configure(factory, connectionFactory);
return factory;
}
}