您使用的是什么版本?
我刚复制了你们的集装箱工厂,它对我来说很好(2.1.3)。
btw,从2.0版开始,您可以添加
concurrency
到
@RabbitListener
它将覆盖容器工厂中的任何值。
/**
* Set the concurrency of the listener container for this listener. Overrides the
* default set by the listener container factory. Maps to the concurrency setting of
* the container type.
* <p>For a
* {@link org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer
* SimpleMessageListenerContainer} if this value is a simple integer, it sets a fixed
* number of consumers in the {@code concurrentConsumers} property. If it is a string
* with the form {@code "m-n"}, the {@code concurrentConsumers} is set to {@code m}
* and the {@code maxConcurrentConsumers} is set to {@code n}.
* <p>For a
* {@link org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer
* DirectMessageListenerContainer} it sets the {@code consumersPerQueue} property.
* @return the concurrency.
* @since 2.0
*/
String concurrency() default "";
也不相关,但你不应该这样做
rabbitAdmin.declareExchange(dirExchange)
在bean声明中—在应用程序上下文生命周期中连接到rabbitmq太早了。将交换、队列和绑定添加为
@Bean
S和管理员将自动查找并声明它们。