0
votes

I try to use the dead letter exchange with annotations in my java code. Maybe is my assumption wrong how it should work. But in my method processMpcMessage I deserialize the message from a Queue into a POJO. If I get a IllegalargumentException I want that the message is put onto a dead letter queue. I configured the deadletter exchange and routing key see my code example. If I throw "throw new AmqpRejectAndDontRequeueException(msg, exception);" I expect that the message I consumed earlier is put onto the dead letter queue. I get how ever the following debug message:

2019-02-07 13:35:42,009 [SimpleAsyncTaskExecutor-1] DEBUG {} - org.springframework.amqp.rabbit.listener.BlockingQueueConsumer - Rejecting messages (requeue=false)

Any advise is welcome Regards Dirk

    @RabbitListener(bindings = @QueueBinding(
                                value = @Queue(
                                        value = "${mpc.inbound.receive.queue}",
                                        durable = "true",
                                        arguments = {
                                                @Argument(name = "x-dead-letter-exchange", value = "${mpc.inbound.dead.letter}"),
                                                @Argument(name = "x-dead-letter-routing-key", value = "${mpc.inbound.receive.error.routing.key}"),
                                                @Argument(name = "defaultRequeueRejected", value = "false")
                                        }),
                                        exchange = @Exchange(value = "${mpc.inbound.exchange}",
                                        type = ExchangeTypes.TOPIC, durable = "true"),
                                        key = "${mpc.inbound.routing.key}"
                                ))
public void processMPCMessage(final Message message) {
//Here the message is deserialized in to a java object and this is where I want to throw a exception. 
try{
}catch(IllegalArgumgenException ex){
    throw new new AmqpRejectAndDontRequeueException(" a error message", ex);
}


}
1

1 Answers

1
votes

Does the queue already exist?

Queues are idempotent; you can't change their properties (arguments) after they are created. Delete it first so it will be recreated.

If that's not it, turn on DEBUG logging to see what's going on.