码迷,mamicode.com
首页 > 编程语言 > 详细

Spring AMQP 发送消息到 RabbitMQ 收到 x-queue-type 错误

时间:2019-10-13 15:15:25      阅读:103      评论:0      收藏:0      [点我收藏+]

标签:received   false   添加   one   直接   发送消息   wiki   queue   lan   

在使用 Spring AMQP 发送消息到 RabbitMQ 的时候收到错误信息:

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=10

 

上面的错误信息已经很明显了,说明的是发送消息的队列参数中少了 x-queue-type 这个参数。

在代码中,我们创建队列的参数为:

return new Queue(MY_QUEUE_NAME, NON_DURABLE);

这直接创建队列的参数少了 args.put("x-queue-type", "classic");

因此,我们需要在创建队列的时候添加上面的参数。

修改代码为:

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 中的代码:

https://github.com/cwiki-us-demo/tutorials/blob/master/spring-amqp/src/main/java/com/baeldung/springamqp/simple/HelloWorldMessageApp.java

https://blog.ossez.com/archives/3050

Spring AMQP 发送消息到 RabbitMQ 收到 x-queue-type 错误

标签:received   false   添加   one   直接   发送消息   wiki   queue   lan   

原文地址:https://www.cnblogs.com/huyuchengus/p/11666277.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!