0

I'm trying to understand how to set the redelivery time for basic.nacked messages. Some important info is that I'm using quorum queues with a redelivery amount of 5 times. Consider the following scenario:

What is happening Now:

  1. Producer sends message: Message X
  2. Consumer handles Message X and runs into an error, in the error handler I use basic.nack()
  3. Message is resent to original queue. Consumer immediately handles that task again.
  4. This process repeats until the redelivery amount has been reached and then it's dead-lettered.

What I actually want:

I want the message that is requeued to wait a few seconds (3-5 sec or something) before it's once again handled by a consumer. I want to do this due to the fact that I'm using OCC & there are instances where delaying the message redelivery solves consistency issues. (for the people wondering why in god's name I need this).

I was able to do this with NATS streaming server, but I don't know how to implement it with rabbitMQ.

Additional info: I'm using amqplib (typescript) as the client and prefetch is set to 10 globally. I'm using AWS MQ for Rabbit as my rabbitMQ host

1 Answers1

0

As far as i know, there isn't a way to add RabbitMQ Delayed Message Plugin to AWS MQ. You can:

  • create a new dead_letter_queue with x-message-ttl option, with value you need (3-5 secs)
  • for this dead_letter_queue dead letter exchange will be your original exchange
  • create dead_letter_exchange connected with dead_letter_queue

Workflow:

  1. Consumer nack message
  2. Message goes to dead_letter_exchange
  3. From dead_letter_exchange it goes to dead_letter_queue
  4. In dead_letter_queue message waits x-message-ttl time
  5. Message marks as dead and goes to your original exchange (and then to your original queue)

enter image description here

  • Yeah, I scowered the docs for the redelivery plugin inside MQ. But sadly enough config files are for some reason only for the amqp engine & not the rabbit engine. I was thinking of something similar you proposed here. I'm going to do what you propose, but with a rollback queue as well I suppose. – Berkan Alci Aug 15 '22 at 18:05