amqp.exceptions.PreconditionFailed: Queue.declare: (406) PRECONDITION_FAILED - inequivalent arg

3.1k Views Asked by At

I am trying to consume Celery task from a Rabbitmq queue.

My tasks.py is below

from celery import Celery

app=Celery('tasks',broker ='amqp://localhost//')

app.conf.task_default_queue = 'e'

@app.task(name='hello')
def hello():
  print('hello')

and

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()

But I am getting this error amqp.exceptions.PreconditionFailed: Queue.declare: (406) PRECONDITION_FAILED - inequivalent arg. I dont know why?

0

There are 0 best solutions below