(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);
}
文章来源地址https://www.toymoban.com/news/detail-825717.html
文章来源:https://www.toymoban.com/news/detail-825717.html
到了这里,关于RabbitMQ多线程配置和异常解决办法的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!