我正在尝试从 Rabbitmq 队列中使用 Celery 任务。
我的tasks.py在下面
from celery import Celery
app=Celery('tasks',broker ='amqp://localhost//')
app.conf.task_default_queue = 'e'
@app.task(name='hello')
def hello():
print('hello')
和
import pika
connection = pika.BlockingConnection(
pika.ConnectionParameters(host='localhost'))
channel = connection.channel()
channel.queue_declare(queue='e')
def callback(ch, method, properties, body):
print(" [x] Received %r" % body)
channel.basic_consume(
queue='e', on_message_callback=callback, auto_ack=True)
print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()
但我收到此错误 amqp.exceptions.PreconditionFailed: Queue.declare: (406) PRECONDITION_FAILED - inequivalent arg。我不知道为什么?