6.2. 创建出站连接
要连接到远程服务器,请使用 连接 URL 调用 container::connect () 方法。这通常在 messaging_handler::on_container_start () 方法内完成。
示例:创建传出连接
class example_handler : public proton::messaging_handler {
void on_container_start(proton::container& cont) override {
cont.connect("amqp://example.com");
}
void on_connection_open(proton::connection& conn) override {
std::cout << "The connection is open\n";
}
};
有关创建安全连接的详情,请参考 第 7 章 安全性。