温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

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

发布时间:2020-08-01 12:10:53 来源:网络 阅读:575 作者:HoneyMoose 栏目:大数据

在使用 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


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI