We have a SpringBoot service implementation in which we are using delayed messaging with the below setup:
- Initial queue (Queue 1) that gets the message has a TTL set, the queue also has a dead letter exchange mentioned with a specific dead letter routing key.
- Another queue (Queue 2) is bound to the DLX of the previous queue with the routing key which is set as the dead letter routing key
- A consumer listens to the messages on Queue 2.
The delayed messaging seems to work as expected but I am seeing an issue with messages getting redelivered in certain scenarios.
If I have a debug point in my consumer and keep the message just after reading it for some time then once the current message has been processed consumer gets another message which has the below properties:
- Redelivered property as true.
- Property deliveryAttempt as 1
- Only the first message has an
x-death
header and redelivered messages do not seem to have it.
The attempt to deliver the message is done 3 times as many times as I pause the consumer using the debug point each time after reading each redelivered message.
My understanding was that the acknowledgment mode by default is AUTO so once the consumer has read the message then it would not be redelivered?
I have tried using maxAttempts=1
property but does not seem to help.
I am using the spring cloud stream to create the consumers and the queues.