Can RabbitMQ consumer configure to consume only a defined number of attempts for the same message

和自甴很熟 提交于 2019-12-02 07:00:01

So yes I believe this can be done. You will need to cache the delivery tags of the messages received and also keep track of a reject count. Once the reject count for a particular message is great that five and then publish the message to another queue. You will also need to ACK back to RabbitMQ for the message recieved and likely create a new message (with a new delivery tag) and publish it.

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.: just make comment more visible

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!