Category: RabbitMQ

How to customize the message in RabbitMQ while dead-lettering

When you are using Spring AMQP api to publish and consume the messages it provides the option to  consumer to Reject the message when we get AmqpRejectAndDontRequeueException.

Spring AMQP takes are of pushing the message to corresponding dead-letter exchange when this exception is occurred with status as Rejected.

But we don’t have any idea about which exception caused this particular message to be dead-letterd as spring amqp doesn’t provide it and it don’t have option to customize the message also.

Along with Spring-retry and spring AMQP api we can customize the message before its is dead-lettered.

https://stackoverflow.com/questions/33810450/how-to-specify-additional-info-on-a-rabbit-message-when-its-dead-lettered

https://docs.spring.io/spring-amqp/docs/latest_ga/reference/htmlsingle/#async-listeners

https://www.infobip.com/en/engineering/rabbitmq-message-processing-and-retry-logic

Here is the sample Spring boot application,

https://github.com/nkrishnakumarmca/RabbitMQ_FailureRetry