RabbitMQ 消费者是否可以配置为仅对同一消息使用定义的尝试次数

Can RabbitMQ consumer configure to consume only a defined number of attempts for the same message(RabbitMQ 消费者是否可以配置为仅对同一消息使用定义的尝试次数)
本文介绍了RabbitMQ 消费者是否可以配置为仅对同一消息使用定义的尝试次数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

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 消费者是否可以配置为仅对同一消息使用定义的尝试次数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)