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
添加回答
举报