1 Star 0 Fork 0

shoothzj/qpid-python-demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
consumer.py 825 Bytes
一键复制 编辑 原始数据 按行查看 历史
shoothzj 提交于 2023-04-16 22:24 . first commit
import sys
from proton.handlers import MessagingHandler
from proton.reactor import Container
class AMQPConsumer(MessagingHandler):
def __init__(self, server_url, target_address):
super(AMQPConsumer, self).__init__()
self.server_url = server_url
self.target_address = target_address
def on_start(self, event):
conn = event.container.connect(self.server_url)
event.container.create_receiver(conn, self.target_address)
def on_message(self, event):
print(f"Received message: {event.message.body}")
event.connection.close()
if __name__ == "__main__":
server_url = "amqp://localhost:5672"
target_address = "example_queue"
try:
Container(AMQPConsumer(server_url, target_address)).run()
except KeyboardInterrupt:
sys.exit(0)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/shoothzj/qpid-python-demo.git
git@gitee.com:shoothzj/qpid-python-demo.git
shoothzj
qpid-python-demo
qpid-python-demo
main

搜索帮助