I assume that you know what Dead Letter Exchange (DLX) is in RabbitMQ. If you don’t then you should read the  documentation. In short, if your message is not consumed for some reason, it gets put into another queue for investigation so on. Make sure that the dead letter exchange and the queue is declared before others otherwise messages will be silently dropped.

Setup

I assume that you already have a consumer application working fine. Let’s add a dead letter exchange and queue to it.

## The current properties
ExchangeType: direct
ExchangeName: user
RoutingKey: create
QueueName: user_create

## New DLX properties
ExchangeType: fanout
ExchangeName: user_dlx
QueueName: user_create_dlx

#go #rabbitmq #golang

Creating a RabbitMQ DLX (Dead Letter Exchange) example with Golang
6.75 GEEK