Reputation: 367
I have read about RabbitMQ & it's techniques on handling the events which fail to process at consumers (not acknowledged messages, expired ttl-s etc.). RabbitMQ DLX
The way this is working (as I understand) is setting a Dead Letter Exchange to the processing queue. So far so good, when the events are failing I can see that the Dead letter queue is getting it's messages saved there.
But how do I consume these messages saved there ?! In my case I want to re-process them after their TTL in dlq has expired, but in .NET Core (C#), I couldn't find a way or an implementation how to achieve this. I could also agree with other solutions like creating a background worker to check for dead-messages etc.
Can this be achieved ? If yes, please help me understand what I need to do to get this working
Upvotes: 0
Views: 13773
Reputation: 212
You may want to consider attaching the original queue's source exchange as the dead letter exchange of the DLQ, which makes the original queue and the DLQ the DLQs to each other, forming a re-try loop.
The added DLQ serves as a temp store of retry messages, and a retry delay buffer with the TTL mechanism. Messages timing out in the DLQ get auto-pushed back to the original queue for retry. The original queue's consumer handles both first-time and retry messages.
To avoid an infinite loop of retries, a retry counter would be set in the message; and the consumer of the original queue needs to eventually break the retry loop based on that counter.
Upvotes: 1
Reputation: 1954
You need to configure a "dead letter queue" to handle messages that have been rejected or undelivered. Using the RabbitMQ Client library, you can bind a consumer to that configured queue and retrieve the messages from it. From there you decide in code what you want to do to reprocess/reject them completely.
I've found a useful step by step guide for you to follow with more detail: https://medium.com/nerd-for-tech/dead-letter-exchanges-at-rabbitmq-net-core-b6348122460d
Upvotes: 0