在使用 Spring AMQP 发送消息到 RabbitMQ 的时候收到错误信息:html
inequivalent arg 'x-queue-type' for queue 'com.ossez.real.estate' in vhost '/': received none but current is the value 'classic' of type 'longstr', class-id=50, method-id=10java
上面的错误信息已经很明显了,说明的是发送消息的队列参数中少了 x-queue-type 这个参数。git
在代码中,咱们建立队列的参数为:github
return new Queue(MY_QUEUE_NAME, NON_DURABLE);
这直接建立队列的参数少了 args.put("x-queue-type", "classic");spring
所以,咱们须要在建立队列的时候添加上面的参数。ide
修改代码为:ui
Map<String, Object> args = new HashMap<>();
// // set the queue with a dead letter feature
args.put("x-queue-type", "classic");
return new Queue(MY_QUEUE_NAME, NON_DURABLE, false, false, args);
请参考 GitHub 中的代码:code