我尝试使用带有注释死信交换我的Java代码。也许是我的假设错了,它应该如何工作。但是,在我的方法processMpcMessage我反序列化从队列中的消息成一个POJO。如果我得到一个抛出:IllegalArgumentException我想要的消息放到死信队列。我配置了死信交换和路由选择关键看我的代码示例。如果我把“抛出新AmqpRejectAndDontRequeueException(味精,除外);”我希望我刚才所消耗的消息被放置到死信队列。我得到怎么过下面的调试消息:
2019年2月7日13:35:42009 [SimpleAsyncTaskExecutor-1] DEBUG {} - org.springframework.amqp.rabbit.listener.BlockingQueueConsumer - 拒绝消息(重新排队=假)
任何意见是值得欢迎的问候德克
@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);
}
}
是否队列已经存在?
队列是幂等;你不能改变它们的属性(参数)在创建之后。先删除它,所以它会被重新创建。
如果这不是它,打开调试日志,看看发生了什么事情。