6.4. 配置故障转移
AMQ C++ 允许您配置多个连接端点。如果连接到一个失败,客户端会尝试连接到列表中的下一个。如果列表耗尽,该过程会启动。
要指定备用连接端点,请将 failover_urls reconnect 选项设置为连接 URL 列表。
示例:配置故障切换
std::vector<std::string> failover_urls = {
"amqp://backup1.example.com",
"amqp://backup2.example.com"
};
proton::connection_options opts {};
proton::reconnect_options ropts {};
opts.reconnect(ropts);
ropts.failover_urls(failover_urls);
container.connect("amqp://primary.example.com", opts);