1 回答

TA貢獻1966條經驗 獲得超4個贊
有@RabbitListener一個autoStartup選項:
/**
* Set to true or false, to override the default setting in the container factory.
* @return true to auto start, false to not auto start.
* @since 2.0
*/
String autoStartup() default "";
我想你最好有兩個單獨的@RabbitListeners:一個用于配置隊列,另一個用于非自動啟動。配置準備就緒后,您需要從中獲取第二個容器的容器RabbitListenerEndpointRegistry.getListenerContainer()并調用其start(). 你id也可以在那一秒配置@RabbitListener:
/**
* The unique identifier of the container managing for this endpoint.
* <p>If none is specified an auto-generated one is provided.
* @return the {@code id} for the container managing for this endpoint.
* @see org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry#getListenerContainer(String)
*/
String id() default "";
有關詳細信息,請參閱文檔:https://docs.spring.io/spring-amqp/docs/2.1.7.RELEASE/reference/html/#async-annotation-driven
添加回答
舉報