406, "PRECONDITION_FAILED - inequivalent arg 'durable' for queue 'hello' in vhost '/': received 'true' but current is 'false'"


環境描述:

  1. Erlong使用的是:otp_win64_21.0.1

  2. RabbitMQ使用的是:rabbitmq-server-3.7.8

  3. Windows10x64

問題描述:

  測試RabbitMQ時報:406, "PRECONDITION_FAILED - inequivalent arg 'durable' for queue 'hello' in vhost '/': received 'true' but current is 'false'"

問題代碼:

  channel.queue_declare(queue='hello',durable=True) # durable 隊列持久化

查看源碼:

# def queue_declare(self, # channel.queueDeclare 用來創建隊列,有5個參數:
# queue, # String queue, 隊列名;
# passive=False,
# durable=False, # boolean durable, 該隊列是否需要持久化
# exclusive=False, # boolean exclusive,該隊列是否為該通道獨占的(其他通道是否可以消費該隊列)
# auto_delete=False, # boolean autoDelete,該隊列不再使用的時候,是否讓RabbitMQ服務器自動刪除掉;
# arguments=None)

  passive:是屈服的意思,將passive設為True,問題解決。

正確代碼:

  channel.queue_declare(queue='hello',durable=True,passive=True) # durable 隊列持久化


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM