Something wrong with pika/rabbitmq arguments? (Error while passing arguments in pika)

23 views Asked by At

I'm trying to use pika and rabbitmq to test dead letter exchange, but this keeps happening: pika.exceptions.ChannelClosedByBroker: (406, "PRECONDITION_FAILED - inequivalent arg 'x-message-ttl' for queue 'mainq' in vhost '/': received the value '4000' of type 'signedint' but current is none") and it's the same with alternate-exchange...

Here is my code: client.py

import pika, uuid
from pika.exchange_type import ExchangeType

# Consuming part of the client.
creds = pika.PlainCredentials('sth', 'sth')
params = pika.ConnectionParameters(host='localhost', credentials=creds)
connection = pika.BlockingConnection(parameters=params)
ch = connection.channel()

ch.exchange_declare('main', exchange_type='direct')

ch.basic_publish(exchange='main', routing_key='home', body="Sth")

print('Sent Message Sth.')
connection.close()

server.py

import pika


creds = pika.PlainCredentials('sth', 'sth')
params = pika.ConnectionParameters('localhost', credentials=creds)
connection = pika.BlockingConnection(parameters=params)
ch = connection.channel()

ch.exchange_declare('main', exchange_type='direct', arguments={'alternative-exchange': 'altn'})
ch.exchange_declare('dlx', exchange_type='fanout')

ch.queue_declare(queue='mainq', arguments={'x-dead-letter-exchange': 'dlx',
                                           'x-message-ttl': 4000,
                                           'x-max-lengh': 100})
ch.queue_bind('mainq', 'main', routing_key='home')

ch.queue_declare('dlxq')
ch.queue_bind('dlxq', 'dlx')

def callback(ch, method, properties, body):
    print(f'DLX: {body}')


ch.basic_consume('dlxq', on_message_callback=callback, auto_ack=True)

print('Starting consuming...')
ch.start_consuming()

I tried running server first and then client. I also tried deleting exchanges and queues manually.

0

There are 0 answers