【问题标题】:pika.exceptions.ChannelClosedByBroker: (405, "RESOURCE_LOCKED - cannot obtain exclusive access to locked queue 'q1' in vhost '/'. It could bepika.exceptions.ChannelClosedByBroker: (405, "RESOURCE_LOCKED - 无法获得对 vhost '/' 中锁定队列 'q1' 的独占访问权限。它可能是
【发布时间】:2021-12-25 14:03:38
【问题描述】:

我写的接收者如下:

import pika

connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
ch =    connection.channel()

ch.exchange_declare(exchange='ex1', exchange_type='fanout')
ch.queue_declare(queue='q1',exclusive=True)
ch.queue_bind(exchange='ex1',queue='q1')
print("wating for log")

def callback(ch, method, properties, body):
    print(f'This is from reciver {body}')
ch.basic_consume(queue='q1',on_message_callback=callback, auto_ack=True)
ch.start_consuming()

运行时出现此错误:

Traceback (most recent call last):
  File "receiver2.py", line 7, in <module>
    ch.queue_declare(queue='q1',exclusive=True)
  File "/train/lib/python3.8/site-packages/pika/adapters/blocking_connection.py", line 2506, in queue_declare
    self._flush_output(declare_ok_result.is_ready)
  File "/train/lib/python3.8/site-packages/pika/adapters/blocking_connection.py", line 1339, in _flush_output
    raise self._closing_reason  # pylint: disable=E0702
pika.exceptions.ChannelClosedByBroker: (405, "RESOURCE_LOCKED - cannot obtain exclusive access to locked queue 'q1' in vhost '/'. It could be originally declared on another connection or the exclusive property value does not match that of the original declaration.")

【问题讨论】:

    标签: python-3.x rabbitmq rabbitmq-exchange


    【解决方案1】:

    我删除了queue_declare中的队列名称(q1)

    ch.queue_declare(queue='q1',exclusive=True)
    

    ch.queue_declare(queue='',exclusive=True)
    

    【讨论】:

      猜你喜欢
      • 2016-08-05
      • 1970-01-01
      • 1970-01-01
      • 2013-10-22
      • 1970-01-01
      • 2016-07-14
      • 1970-01-01
      • 1970-01-01
      • 2014-04-08
      相关资源
      最近更新 更多