簡體   English   中英

如何使用pika從一個使用者的2個RabbitMQ隊列中異步使用

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM