首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >cxf故障切换恢复

cxf故障切换恢复
EN

Stack Overflow用户
提问于 2012-10-04 21:37:59
回答 2查看 933关注 0票数 3

我有一个cxf JAX-WS客户机。我添加了故障转移策略。问题是客户端如何从备份解决方案恢复并再次使用主URL?因为现在客户端将切换到辅助URL后仍然存在,将不会使用主要URL,即使此URL再次可用。

客户端部分的代码是:

代码语言:javascript
复制
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(GatewayPort.class);
factory.setAddress(this.configFile.getPrimaryURL());

FailoverFeature feature = new FailoverFeature();
SequentialStrategy strategy = new SequentialStrategy();
List<String> addList = new ArrayList<String>();
addList.add(this.configFile.getSecondaryURL());
strategy.setAlternateAddresses(addList);
feature.setStrategy(strategy);

List<AbstractFeature> features = new ArrayList<AbstractFeature>();
features.add(feature);
factory.setFeatures(features);

this.serviceSoap = (GatewayPort)factory.create();

Client client = ClientProxy.getClient(this.serviceSoap);
if (client != null)
{
    HTTPConduit conduit = (HTTPConduit)client.getConduit();
    HTTPClientPolicy policy = new HTTPClientPolicy();
    policy.setConnectionTimeout(this.configFile.getTimeout());
    policy.setReceiveTimeout(this.configFile.getTimeout());
    conduit.setClient(policy);
}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-10-17 12:07:58

您可以将主要URL添加到备用地址列表,而不是将其设置为JaxWsProxyFactoryBean。这样,由于您使用的是SequentialStrategy,所以将首先检查每个服务调用的主URL,如果检查失败,则将尝试第二个URL。

票数 4
EN

Stack Overflow用户

发布于 2013-11-07 19:41:19

您也可以尝试另一种CXF failover feture with failback。

https://github.com/jaceko/cxf-circuit-switcher

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12728523

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档