I am using RabbitMQ and I have a queue that holds email messages. My consumer service de-queues messages and attempts to send them. If, for any reason, my consumer cannot se
Although this is an old question I think you can now easily do this with the combination of dead letter exchanges and x-death header array added once a message is dead lettered:
The dead-lettering process adds an array to the header of each dead-lettered message named x-death. This array contains an entry for each dead lettering event, identified by a pair of {queue, reason}. Each such entry is a table that consists of several fields:
queue: the name of the queue the message was in before it was dead-lettered
reason: reason for dead lettering, see below
time: the date and time the message was dead lettered as a 64-bit AMQP 0-9-1 timestamp
exchange - the exchange the message was published to (note that this will be a dead letter exchange if the message is dead lettered multiple times)
routing-keys: the routing keys (including CC keys but excluding BCC ones) the message was published with
count: how many times this message was dead-lettered in this queue for this reason
original-expiration (if the message was dead-letterered due to per-message TTL): the original expiration property of the message. The expiration property is removed from the message on dead-lettering in order to prevent it from expiring again in any queues it is routed to.
Read this great article for more info
check this draw: