I am using spring-amqp and a dead letter queue to deal with failed messages but I want to increment the ttl for each retry(like a exponential backoff).
I have tried to get the message in a custom error handler and add the expiration header so rabbit can use this value instead of the ttl but the custom header is not published.
Is it possible to do that? I have seen the RejectAndDontRequeueRecoverer but I am not sure if it is the best way to do that or even it is possible.
The RejectAndDontRequeueRecoverer
throws AmqpRejectAndDontRequeueException
which ends up with the logic like:
this.channel.basicNack(deliveryTag.getAsLong(), true,
ContainerUtils.shouldRequeue(this.defaultRequeueRejected, ex, logger));
So, there is no message involved in the process, just its deliveryTag
, which makes the broker to perform its DLX functionality.
For the message modification, you might need to look into a manual solution:
nack
the current message;