6.2. 创建传出连接
要连接到远程服务器,请使用 连接 URL 调用 Container.connect() 方法。这通常在 MessagingHandler.on_start() 方法内完成。
示例:创建出站连接
class ExampleHandler(MessagingHandler):
def on_start(self, event):
event.container.connect("amqp://example.com")
def on_connection_opened(self, event):
print("Connection", event.connection, "is open")
有关创建安全连接的详情请参考 第 7 章 安全性。