兔子MQ& Spring Amqp重试而不阻塞消费者 [英] RabbitMQ & Spring amqp retry without blocking consumers
问题描述
我正在使用RabbitMQ和Spring amqp,在这里我不希望丢失消息.通过使用指数退避策略进行重试,我潜在地阻止了我的消费者,他们可能正在处理他们可以处理的消息.我想为失败的消息提供几天的时间,以尝试采用指数回退策略,但是我不想让消费者阻止几天,并且希望它继续处理其他消息.
我知道我们可以使用ActiveMQ实现这种功能(在将来的某个时刻重试消息(ActiveMQ)),但是找不到RabbitMQ的类似解决方案.
有没有办法通过Spring amqp和RabbitMQ实现这一目标?
您可以通过死信交换来实现.拒绝消息并将其路由到DLE/DLQ,并有一个单独的侦听器容器,该容器从DLQ中使用,并根据需要停止/启动该容器.
或者,代替第二个容器,您可以使用RabbitTemplate
receive
(或receiveAndConvert
)方法(按计划)轮询DLQ,并将失败的消息路由回主队列./p>
I'm working with RabbitMQ and Spring amqp where I would prefer not to lose messages. By using exponential back off policy for retrying, I'm potentially blocking my consumers which they could be working off on messages they could handle. I'd like to give failed messages several days to retry with the exponential back off policy, but I don't want a consumer blocking for several days and I want it to keep working on the other messages.
I know we can achieve this kind of functionality with ActiveMQ(Retrying messages at some point in the future (ActiveMQ)), but could not find a similar solution for RabbitMQ.
Is there a way to achive this with Spring amqp and RabbitMQ?
You can do it via the dead letter exchange. Reject the message and route it to the DLE/DLQ and have a separate listener container that consumes from the DLQ and stop/start that container as needed.
Or, instead of the second container you can poll the DLQ using the RabbitTemplate
receive
(or receiveAndConvert
) methods (on a schedule) and route the failed message(s) back to the primary queue.
这篇关于兔子MQ& Spring Amqp重试而不阻塞消费者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!