rabbitmq – How to add exponentially increasing delay for each retry in Spring AMQP?

Let’s say I define two queues named events and events.dlq. Both queues are dead letter queues of each other.

As far as I understand, there are two ways to add delay to retry: (other than using plugin)

1- Adding x-message-ttl header while creating events.dlq. Thus, messages expired here go to events queue. The consumer then receives messages from the events queue.

Disadvantage: It is impossible to change the x-message-ttl header within the rejected message. In other words, exponential increase functionality cannot be added in the message delay time.

2- BackoffOptions value is defined in RetryOperationsInterceptor bean. Thus, a delay is added to the messages to be retried.

Disadvantage: Since this delay is on the consumer side, the consumer is blocked throughout the delay. (in the first option, the message was expiring in the broker, in the second option, the delay is happening in the consumer)

Here are the questions based on the above options:

Question 1: Is what I mentioned above true? If it is wrong, please correct.

Question 2: What is the most optimized way to add exponentially increasing delay for retry in a build with concurrent consumers?

Read more here: Source link