rabbitmq - 返回rabbitmq交换声明,队列声明和队列绑定ok
问题描述
我对 rabbitmq 和 asyncio 很陌生。我想在此处的rabbitmq示例代码之后编写一个初始化函数 https://github.com/pika/pika/blob/master/examples/asynchronous_publisher_example.py
在示例代码中,它使用一个回调链来声明交换、声明队列和绑定队列。这正是我想要在我的初始化功能中实现的。我想知道是否有可能在绑定队列正常之后,也就是执行此回调时,使用 asyncio 以某种方式“获得通知”。https://github.com/pika/pika/blob/master/examples/asynchronous_publisher_example.py#L214 并返回我的初始化函数。
我不想使用 BlockingChannel,因为我正在修改一些现有代码,这不是一个选项。
非常感谢大家!
最小的代码集可以是这样的
def initialize(self):
self.declare_exchange()
# wait for queue bind ok, how to do?
return
def declare_exchange(self):
self.channel.exchange_declare(
....
callback = self.declare_queue
)
def declare_queue(self):
self.channel.queue_declare(
...
callback = self.bind_queue
)
def bind_queue(self):
self.channel.queue_bind(
...
callback = self.queue_bind_ok
)
def queue_bind_ok(self):
# notify initialization done, how to do?
解决方案
推荐阅读
- python - 尝试导入熊猫时在 Python 中找不到模块错误
- angularjs - Gulp 包解决方案在 SPFX 中部署时不使用 Angular.json 文件
- javascript - 用点替换 coma - Google Sheet 找不到替换功能
- javascript - function.call() 返回全局 this
- django - Django bootstrap-pagination 使用继承的模板?
- c# - 在 C# 中检测 MySQL“超时过期”错误的正确方法是什么?
- c# - 如何使用单个标签,以便如果您多次单击它,将显示以下控件?
- embedded - STM32F769DISCO + 使用 ESP8266 的无线连接
- java - 如何修复 Eclipse 中的 JpaRepository 错误?
- regex - 在文本中创建不同的重复值