代码拉取完成,页面将自动刷新
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)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。