Rabbitmq有python错误

时间:2018-04-13 12:53:39

标签: python rabbitmq mq

我已经安装了pip install pika == 0.11.0,因为它显示在自述文件中,之后我尝试了python receiver.py,它给了我以下错误:

 =INT(NETWORKDAYS(K3;L3)/5)+1

即使我没有修改任何东西。我也尝试了spring-amqp示例,这些都有效。你能给我一个关于我应该改变什么的暗示吗?

这是py fille:

  ='Sheet2'!INT(NETWORKDAYS(K3;L3)/5)+1

错误发生在以下行:

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'")

2 个答案:

答案 0 :(得分:2)

默认vhost hello中的队列/已经存在,但它被声明为持久。在执行代码之前删除此队列或从Python声明它是持久的:

channel.queue_declare(queue='hello', durable=True)

请参阅消息持久性&#39;部分&#39; the tutorial

答案 1 :(得分:0)

# This script will publish MQ message to my_exchange MQ exchange

import pika
#credentials = pika.PlainCredentials('the_user', 'the_pass')
#connection = #pika.BlockingConnection(pika.ConnectionParameters('localhost', 5672, '/', pika.PlainCredentials('guest', 'guest')))
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost', 5672, 'test', pika.PlainCredentials('admin', 'password1243')))
channel = connection.channel()

#channel.queue_declare(queue='items-queue', durable=Ture)
channel.queue_declare(queue='dx-naas', durable=True)


channel.basic_publish(exchange='my-exchange', routing_key='my-routing-key', body='Hello World!')

print("[x] Sent 'Hello World!'")

connection.close()