Posting messages in two RabbitMQ queues instead of one (using py-amqp)
I have this weird problem using py-amqp and Flopsy . I wrote a publisher that sends messages to the RabbitMQ server and I would like to send it to a specified queue. This is not possible in the Flopsy module, so I changed it by adding a parameter and a line to declare the queue in the _init__ method of the Publisher object
def __init__(self, routing_key=DEFAULT_ROUTING_KEY,
exchange=DEFAULT_EXCHANGE, connection=None,
delivery_mode=DEFAULT_DELIVERY_MODE, queue=DEFAULT_QUEUE):
self.connection = connection or Connection()
self.channel = self.connection.connection.channel()
self.channel.queue_declare(queue) # ADDED TO SET UP QUEUE
self.exchange = exchange
self.routing_key = routing_key
self.delivery_mode = delivery_mode
The channel object is part of the py-amqplib library
The problem I got was that even if it sends messages to the specified queue, it also sends messages to the default queue. AS on this system we expect to send quite a lot of messages, we don't want to stress that the system creates useless duplicates ... I tried to debug the code and go into the py-amqplib library, but I am not able to figure out what is the error or the step is missing. Also, I cannot find any py-amqplib documentation formula outside of the code.
Any ideas on why this is happening and how to fix it?
a source to share
Ok, I think I have it. unless someone else has a better idea. I checked this AMQP tutorial I assumed the publisher needs to know the queue, but it doesn't, you need to send a message to exchange and the consumer will declare that the queue is associated with the exchange. This allows different send and receive options, as you can see in the tutorial.
So I have included the exchange information to both the publisher and the consumer without using a call queue_declare
and it seems to work fine.
a source to share