问题描述
RabbitMQ能否以某种方式运行,我可以定义我的消费者它有限制使用相同的消息。即我的消费者用enqueue = true做一个基本的Reject。并且它会无限地继续听同样的信息。我不是在谈论队列方面的TTL。但是对消费者的控制/配置告诉我只想消耗它5次,然后将其发送到另一个队列。这可以实现吗?
Does RabbitMQ capable in a way, I can define my consumer that it has a limit of consuming the same message. i.e my consumer doing a basic Reject with enqueue=true. And it will infinitely keep on listening to the same message. I am not talking about TTL on the queue side. But a control/config over consumer to tell I want to consume this only 5 times and then send it to another queue for instance. Can this be achieved ?
推荐答案
这可以在应用程序级别或通过和死信交换一>。在经纪人方面你不想知道你想要什么(我认为没有理由你不能在消费者方面做到这一点)
This can be done on application level or via TTL and Dead Letter Exchanges. There is not known way to what you want on broker side (and I see no reason why you can't do that on consumer side)
PS:只是使评论更加明显
主要思想是创建自定义ttl属性(在TCP / IP包中为a-la hops计数)并在每次消息时减少它已消耗(并使用新道具重新发布邮件正文)。当它达到零时 - 将其发布到其他队列。
The main idea is to create custom ttl property (a-la hops count in TCP/IP packages) and decrease it every time message been consumed (and re-publish message body with new props). When it reaches zero - publish it to other queue.
这篇关于RabbitMQ使用者是否可以配置为仅使用相同消息的已定义尝试次数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!