RabbitMQ延迟接收
RabbitMQ postponed receive
是否有可能以某种方式推迟监听来自 spring-amqp 中某个特定队列的消息?
在我的用例中,我有一个服务必须监听两个 RabbitMQ 队列上的消息。第一个专用于此服务,第二个用于我服务的多个实例(运行 在不同机器上)的负载平衡作业。
我在 statup 上的服务通过第一个队列接收配置并自行配置。只有在该配置之后,才允许处理来自第二个队列的 "standard" 个作业 - 而不是之前。
我怎样才能做到这一点?使用 @RabbitListener(queues = {queue1,queue2}) 立即开始收听。
我也看过 rabbitmq_delayed_message_exchange,但这不是我想要的,因为它会延迟消息的处理。我不想延迟处理(其他已配置的消费者可以处理工作)。
感谢您的帮助。
@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 "";
我猜你最好有两个单独的 @RabbitListener
s:一个用于配置队列,另一个 not-autoStartuped。配置准备就绪后,您需要从 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
是否有可能以某种方式推迟监听来自 spring-amqp 中某个特定队列的消息?
在我的用例中,我有一个服务必须监听两个 RabbitMQ 队列上的消息。第一个专用于此服务,第二个用于我服务的多个实例(运行 在不同机器上)的负载平衡作业。
我在 statup 上的服务通过第一个队列接收配置并自行配置。只有在该配置之后,才允许处理来自第二个队列的 "standard" 个作业 - 而不是之前。
我怎样才能做到这一点?使用 @RabbitListener(queues = {queue1,queue2}) 立即开始收听。
我也看过 rabbitmq_delayed_message_exchange,但这不是我想要的,因为它会延迟消息的处理。我不想延迟处理(其他已配置的消费者可以处理工作)。
感谢您的帮助。
@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 "";
我猜你最好有两个单独的 @RabbitListener
s:一个用于配置队列,另一个 not-autoStartuped。配置准备就绪后,您需要从 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