当前位置:首页 > 编程笔记 > 正文
已解决

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

来自网友在路上 195895提问 提问时间:2023-11-20 01:21:07阅读次数: 95

最佳答案 问答题库958位专家为你答疑解惑

(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<String, Object> args = new HashMap<String, Object>();
    args.put("x-max-length", 200000);
    return new Queue("xxx", true, false, false, args);
}
 

查看全文

99%的人还看了

猜你感兴趣

版权申明

本文"RabbitMQ多线程配置和异常解决办法":http://eshow365.cn/6-39842-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!