Spring Boot + RabbitMQ Tutorial — Retry and Error Handling Example

In a previous tutorial, we implemented a Spring Boot + RabbitMQ example to understand the various exchange types. In this tutorial, we will be implementing a Spring Boot + RabbitMQ example to retry messages on exception. If the exception still exists after maximum retries, then we put a message in a dead letter queue where it can be analyzed and corrected later.

What Is a Dead Letter Queue?

In English vocabulary, dead letter mail is undeliverable mail that cannot be delivered to the addressee. A dead-letter queue (DLQ), sometimes known as an undelivered-message queue, is a holding queue for messages that cannot be delivered to their destinations due to something.
According to Wikipedia — In message queueing the dead letter queue is a service implementation to store messages that meet one or more of the following failure criteria: