1 回答
TA贡献1821条经验 获得超6个赞
你用的是什么版本?
我刚刚复制了你的容器工厂,它对我来说很好(2.1.3)......
顺便说一句,从 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 还为时过早。将交换、队列和绑定添加为@Beans,管理员会自动找到并声明它们。
添加回答
举报