RabbitMQ多线程配置和异常解决办法

(1)RabbitMQ多线程配置
RabbitMqConfig.java
@Bean("customContainerFactory")
public SimpleRabbitListenerContainerFactory containerFactory(SimpleRabbitListenerContainerFactoryConfigurer configurer, 
        ConnectionFactory connectionFactory) {
    SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
    factory.setConcurrentConsumers(10);  // 设置线程数
    factory.setMaxConcurrentConsumers(10); // 最大线程数
    configurer.configure(factory, connectionFactory);
    return factory;
}
XxxListener.java
@RabbitListener(queues = "xxx", containerFactory = "customContainerFactory")
(2)inequivalent arg 'x-max-length' for queue 'xxx' in vhost '/': received none but current is the value '200000' of type 'long',异常解决办法
RabbitMqConfig.java
@Bean
public Queue xxx() {
    Map args = new HashMap();
    args.put("x-max-length", 200000);
    return new Queue("xxx", true, false, false, args);
}
 

你可能感兴趣的:(RabbitMQ,rabbitmq)