1 回答
TA貢獻(xiàn)1821條經(jīng)驗(yàn) 獲得超6個(gè)贊
你用的是什么版本?
我剛剛復(fù)制了你的容器工廠,它對(duì)我來說很好(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 "";
此外,不相關(guān),但您不應(yīng)該rabbitAdmin.declareExchange(dirExchange)在 bean 聲明中這樣做 - 在應(yīng)用程序上下文生命周期中連接到 RabbitMQ 還為時(shí)過早。將交換、隊(duì)列和綁定添加為@Beans,管理員會(huì)自動(dòng)找到并聲明它們。
添加回答
舉報(bào)
