[英]how to Asynchronously consume from 2 RabbitMQ queues from one consumer using pika
我正在编写一个需要从两个不同队列中消费的消费者。
1->用于实际消息(事先声明的队列)。
2->用于控制消费者行为的命令消息(由消费者动态声明,并使用特定格式的路由密钥绑定到现有的交换机(每个运行消费者实例都需要一个)
我正在使用选择连接来异步消费。
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)
未声明队列或未调用回调。
另一方面,由于我添加了此代码块,因此实际消息队列中的消息没有被使用。
Pika日志不显示任何错误,也不会使消费者应用程序崩溃。
有谁知道为什么会这样,还是有更好的方法来做到这一点?
您是否在此处查看了示例: http : //pika.readthedocs.org/en/latest/examples/asynchronous_consumer_example.html ?
还有一些阻止示例: http : //pika.readthedocs.org/en/latest/examples/blocking_consume.html http://pika.readthedocs.org/en/latest/examples/blocking_consumer_generator.html
阻止和选择连接比较: http : //pika.readthedocs.org/en/latest/examples/comparing_publishing_sync_async.html
预先发行的pika 0.10.0中的阻止和选择连接速度更快,并且该版本中有许多错误修复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.