【发布时间】:2018-04-13 12:53:38
【问题描述】:
我已经安装了 pip install pika==0.11.0,如自述文件中所示,之后我尝试了 python receiver.py,它给了我以下错误:
Traceback (most recent call last):
File "receive.py", line 9, in <module>
channel.queue_declare(queue='hello')
File "C:\Python36\lib\site-packages\pika\adapters\blocking_connection.py", line 2400, in queue_declare
self._flush_output(declare_ok_result.is_ready)
File "C:\Python36\lib\site-packages\pika\adapters\blocking_connection.py", line 1258, in _flush_output
raise exceptions.ChannelClosed(method.reply_code, method.reply_text)
pika.exceptions.ChannelClosed: (406, "PRECONDITION_FAILED - inequivalent arg 'durable' for queue 'hello' in vhost '/': received 'false' but current is 'true'")
即使我没有修改任何东西。我也尝试了 spring-amqp 示例,这些都有效。你能告诉我我应该改变什么吗?
这些是 py 填充:
import pika
connection = pika.BlockingConnection(pika.ConnectionParameters(
host='localhost'))
channel = connection.channel()
channel.queue_declare(queue='hello')
def callback(ch, method, properties, body):
print(" [x] Received %r" % body)
channel.basic_consume(callback,
queue='hello',
no_ack=True)
print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()
错误出现在以下行:
channel.queue_declare(queue='hello')
【问题讨论】:
-
如果您不显示代码,我们如何帮助您?