問(wèn)題描述
RabbitMQ 在某種程度上是否具有能力,我可以定義我的消費(fèi)者,它具有消費(fèi)相同消息的限制.即我的消費(fèi)者使用 enqueue=true 進(jìn)行基本拒絕.它會(huì)無(wú)限地繼續(xù)收聽(tīng)相同的信息.我不是在談?wù)撽?duì)列方面的 TTL.但是對(duì)消費(fèi)者的控制/配置告訴我只想消費(fèi) 5 次,然后將其發(fā)送到另一個(gè)隊(duì)列.這可以實(shí)現(xiàn)嗎?
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 ?
推薦答案
這可以在應(yīng)用程序級(jí)別或通過(guò) TTL 和 死信交換.在代理方面沒(méi)有你想要的方式(我認(rèn)為你沒(méi)有理由不能在消費(fèi)者方面這樣做)
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.:讓評(píng)論更明顯
主要思想是創(chuàng)建自定義 ttl 屬性(TCP/IP 包中的 a-la 躍點(diǎn)計(jì)數(shù))并在每次使用消息時(shí)減少它(并使用新屬性重新發(fā)布消息體).當(dāng)它達(dá)到零時(shí) - 將其發(fā)布到其他隊(duì)列.
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.
這篇關(guān)于RabbitMQ 消費(fèi)者是否可以配置為僅對(duì)同一消息使用定義的嘗試次數(shù)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!