rajesh.kanakabandi
rajesh.kanakabandi

Reputation: 324

how to Asynchronously consume from 2 RabbitMQ queues from one consumer using pika

I am writing a Consumer that need to consume from two different queues.

1-> for the actual messages(queue declared before hand).

2-> for command messages to control the behavior of the consumer(dynamically declared by the consumer and binds to an existing exchange with a routing key in a specific format(need one for each instance of consumer running))

I am using selection connection to consume async'ly.

    self.channel.basic_qos(prefetch_count = self.prefetch_count)
    log.info("Establishing channel with the Queue: "+self.commandQueue)
    print "declaring command queue"
    self.channel.queue_declare(queue=self.commandQueue,
                                durable = True,
                                exclusive=False,
                                auto_delete=True,
                                callback = self.on_command_queue_declared)

The queue is not being declared or the callback is not getting called.

On the other hand the messages from the actual message Queue are not being consumed since i added this block of code.

Pika logs do not show any errors nor the consumer app crashes.

does anybody know why this is happening or is there a better way to do this?

Upvotes: 2

Views: 5901

Answers (1)

user1778420
user1778420

Reputation: 44

Have you looked at the example here: http://pika.readthedocs.org/en/latest/examples/asynchronous_consumer_example.html ?

And some blocking examples: http://pika.readthedocs.org/en/latest/examples/blocking_consume.html http://pika.readthedocs.org/en/latest/examples/blocking_consumer_generator.html

Blocking and Select connection comparison: http://pika.readthedocs.org/en/latest/examples/comparing_publishing_sync_async.html

Blocking and Select connections in pika 0.10.0 pre-release are faster and there are a number of bug fixes in that version.

Upvotes: -1

Related Questions