[英]Error when using Rebus with RabbitMQ exclusive queues
嘗試使用 Rebus 響應 RabbitMQ 獨占隊列時出現以下異常。
- e {"Queue 'xxxx-xxxx' does not exist"} Rebus.Exceptions.RebusApplicationException
+ InnerException {"The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=405, text=\"RESOURCE_LOCKED - cannot obtain exclusive access to locked queue 'xxxx-xxxx' in vhost '/'. It could be originally declared on another connection or the exclusive property value does not match that of the original d...\", classId=50, methodId=10, cause="} System.Exception {RabbitMQ.Client.Exceptions.OperationInterruptedException}
客戶端將隊列聲明為獨占,並能夠成功地將消息發送到服務器。 服務器處理消息,但在發送響應時拋出異常。
我可以在 Rebus 源代碼 (Rebus.RabbitMq.RabbitMqTransport.cs) 中看到它嘗試拋出上述異常的model.QueueDeclarePassive(queueName)
。
我在這里找到了以下語句
RabbitMQ 將排他性擴展到 queue.declare(包括被動聲明)、queue.bind、queue.unbind、queue.purge、queue.delete、basic.consume 和 basic.get
修改 Rebus 源以簡單地從 CheckQueueExistence 方法返回 true 允許發送響應消息。 所以我的問題是,這是在 Rebus 中使用獨占隊列上的被動聲明的問題,是 RabbitMQ 阻塞了調用,還是我缺少一個基本概念?
Rebus 做model.QueueDeclarePassive(queueName)
事情的原因是,它試圖通過在發送到目標隊列之前驗證目標隊列的存在來幫助您。
這是為了避免發件人去的情況
using var bus = Configure.With(...)
.(...)
.Routing(r => r.TypeBased().Map<string>("does-not-exist"))
.Start();
await bus.Send("I'M LOST 😱");
並且消息丟失了。
這里的問題是 RabbitMQ 仍然使用路由鍵將發送的消息與指向隊列的綁定相匹配,如果不存在匹配的綁定(即使使用 DIRECT 交換類型),消息只是路由到 0 個隊列,因此它丟失了。
如果您提交的 PR 可以配置是否檢查目標隊列是否存在,那么我很樂意(幫助您正確處理並)接受它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.