I am writing a python client to receive work messages from the RabbitMQ broker and process tasks, returning the results to another server. My script, which sends messages to the RabbitMQ browser, runs fine, but my worker throws the following error when running channel.declare_queue (queue = 'task_queue')
pika.exceptions.AMQPChannelError: (406, "PRECONDITION_FAILED - parameters for the queue 'task_queue' in vhost '/' are not equivalent)
Customer:
import pika connection = pika.BlockingConnection(pika.ConnectionParameters(host=cmdargs.server)) channel = connection.channel() channel.queue_declare(queue='task_queue') channel.basic_qos(prefetch_count=1) channel.basic_consume(ProcJobCallback, queue='task_queue') channel.start_consuming()
Server method that interacts with RabbitMQ:
def addNewJob(self, newJob): self.jobList.append(newJob) connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost')) channel = connection.channel() channel.queue_declare(queue='task_queue') for tile in newJob.TileStatus: message = "{0},{1},{2}".format(newJob, tile[0], tile[1]) channel.basic_publish(exchange='', routing_key='task_queue', body=message, properties=pika.BasicProperties(delivery_mode = 2, )) connection.close()
Any help or understanding is greatly appreciated.
EDIT: I found why I got an error with the code above. I indicated delivery_mode = 2 when posting my messages, but when I announced the queue, I forgot to add the Durable = True parameter.
source share