Reputation: 1
I am working on a Spring Boot application using RabbitMQ with a DLQ configuration. After throwing the AmqpRejectAndDontRequeueException, the messages are not sent to the DLQ.
Here is the relevant code and configuration:
RabbitListener:
@RabbitListener(queues = "${notification.queues.dummy.name}", containerFactory = "notificationContainerFactory")
public void processDummyEvent(DummyEventDTO eventDTO, @Header(name = "x-death", required = false) Map<?, ?> death) {
if (shouldRetry(death)) {
log.error("death: {}", death);
log.error("Consuming dummy queue...");
throw new AmqpRejectAndDontRequeueException("Throwing from dummy queue after retrying...");
} else {
log.error("Throwing from dummy queue...");
throw new ImmediateAcknowledgeAmqpException("Discarding message...");
}
}
private boolean shouldRetry(Map<?,?> death) {
return death == null || death.get(COUNT) == null || Integer.parseInt(death.get(COUNT).toString()) < 3;
}
RabbitMQ YML Configuration:
dummy:
declare: true
name: dummy-queue
durable: true
routingKey: dummy-queue-routingKey
exchange:
name: dummy-queue-exchange
durable: true
type: direct
retryCount: 3
arguments:
x-dead-letter-exchange: dummy-dlq-queue-exchange
x-dead-letter-routing-key: dummy-dlq-queue-routingKey
x-queue-mode: lazy
dummy-dlq:
declare: true
name: dummy-dlq-queue
durable: true
routingKey: dummy-dlq-queue-routingKey
exchange:
name: dummy-dlq-queue-exchange
durable: true
type: direct
arguments:
x-dead-letter-exchange: dummy-queue-exchange
x-dead-letter-routing-key: dummy-queue-routingKey
x-queue-mode: lazy
x-message-ttl: 10000
After throwing the AmqpRejectAndDontRequeueException, messages are not being routed to the DLQ. In the RabbitMQ management interface, the queue (dummy-queue) arguments related to DLQ are not visible.
How can I resolve this issue? Why aren't messages being sent to the DLQ after throwing AmqpRejectAndDontRequeueException?
I noticed that the x-death header is coming as null. Also, the queue arguments ara not visible in the RabbitMQ management interface.
Upvotes: 0
Views: 51