您好,登錄后才能下訂單哦!
在使用 Spring AMQP 發(fā)送消息到 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
上面的錯誤信息已經(jīng)很明顯了,說明的是發(fā)送消息的隊列參數(shù)中少了?x-queue-type 這個參數(shù)。
在代碼中,我們創(chuàng)建隊列的參數(shù)為:
return?new?Queue(MY_QUEUE_NAME,?NON_DURABLE);
這直接創(chuàng)建隊列的參數(shù)少了 args.put("x-queue-type", "classic");
因此,我們需要在創(chuàng)建隊列的時候添加上面的參數(shù)。
修改代碼為:
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
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。