我有SpringBoot AMQP应用程序,我为队列设置了死信。无论如何都要在抛出AmqpRejectAndDontRequeueException
我现在有这个
@RabbitListener(bindings = @QueueBinding(
value = @Queue(value = "core.queue",
durable = "true",
arguments = {
@Argument(name = "x-dead-letter-exchange", value = RabbitConfiguration.ERROR_EXCHANGE),
@Argument(name = "x-dead-letter-routing-key", value = RabbitConfiguration.ERROR_ROUTING_KEY)
}
),
exchange = @Exchange(value = "core.exchange"),
key = "core.route")
)
public void errorListener(final Message message) {
try {
.......
} catch (IOException e) {
// I would like to set value for x-first-death-reason or set
// custom header if possible.
throw new AmqpRejectAndDontRequeueException(e.getMessage());
}
}
答案 0 :(得分:1)
没有; amqp协议不允许消费者修改被拒绝的消息。您必须自己发布到DLQ,而不是让RabbitMQ路由它。