問題描述
RabbitMQ 在某種程度上是否具有能力,我可以定義我的消費者,它具有消費相同消息的限制.即我的消費者使用 enqueue=true 進行基本拒絕.它會無限地繼續收聽相同的信息.我不是在談論隊列方面的 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 ?
推薦答案
這可以在應用程序級別或通過 TTL 和 死信交換.在代理方面沒有你想要的方式(我認為你沒有理由不能在消費者方面這樣做)
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)
P.S.:讓評論更明顯
主要思想是創建自定義 ttl 屬性(TCP/IP 包中的 a-la 躍點計數)并在每次使用消息時減少它(并使用新屬性重新發布消息體).當它達到零時 - 將其發布到其他隊列.
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 消費者是否可以配置為僅對同一消息使用定義的嘗試次數的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!