apache cxf_Apache CXF负载平衡和故障转移
apache cxf
最终,我们最终获得了本地开发的负载平衡微库(ESB / UDDI / WS-Addressing似乎是一个有趣的选择,但在我们的情况下这是一个过大的选择)。 是否仅知道Apache CXF已经(几乎)已经支持所有这些功能?
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:jaxws="http://cxf.apache.org/jaxws"xmlns:clustering="http://cxf.apache.org/clustering"xmlns:util="http://www.springframework.org/schema/util"><jaxws:client id="testServiceClient"serviceClass="com.blogspot.nurkiewicz.cxfcluster.SimpleService"address="http://serverA/simple"></jaxws:client></beans>
<jaxws:client id="testServiceClient"serviceClass="com.blogspot.nurkiewicz.cxfcluster.SimpleService"address="http://serverA/simple"><jaxws:features><clustering:failover><clustering:strategy><bean class="org.apache.cxf.clustering.RandomStrategy"><property name="alternateAddresses"><util:list><value>http://serverB/simple</value><value>http://serverC/simple</value><value>http://serverD/simple</value></util:list></property></bean></clustering:strategy></clustering:failover></jaxws:features></jaxws:client>
<cxf:bus><cxf:features><cxf:logging/></cxf:features>
</cxf:bus>
<bean id="abstractLoggingInterceptor" abstract="true"><property name="prettyLogging" value="true"/>
</bean>
<bean id="loggingInInterceptor" class="org.apache.cxf.interceptor.LoggingInInterceptor" parent="abstractLoggingInterceptor"/>
<bean id="loggingOutInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor" parent="abstractLoggingInterceptor"/><cxf:bus><cxf:inInterceptors><ref bean="loggingInInterceptor"/></cxf:inInterceptors><cxf:outInterceptors><ref bean="loggingOutInterceptor"/></cxf:outInterceptors><cxf:outFaultInterceptors><ref bean="loggingOutInterceptor"/></cxf:outFaultInterceptors><cxf:inFaultInterceptors><ref bean="loggingInInterceptor"/></cxf:inFaultInterceptors>
</cxf:bus>
<jaxws:client id="testServiceClient" serviceClass="com.blogspot.nurkiewicz.cxfcluster.SimpleService"><jaxws:features><clustering:loadDistributor><clustering:strategy><bean class="org.apache.cxf.clustering.SequentialStrategy"><property name="alternateAddresses"><util:list><value>http://serverA/simple</value><value>http://serverB/simple</value><value>http://serverC/simple</value><value>http://serverD/simple</value></util:list></property></bean></clustering:strategy></clustering:loadDistributor></jaxws:features></jaxws:client>
<jaxws:client id="testServiceClient" serviceClass="com.blogspot.nurkiewicz.cxfcluster.SimpleService"><jaxws:features><clustering:loadDistributor><clustering:strategy><bean class="org.apache.cxf.clustering.SequentialStrategy"><property name="alternateAddresses" ref="alternateAddresses"/></bean></clustering:strategy></clustering:loadDistributor></jaxws:features></jaxws:client><util:list id="alternateAddresses" list-class="java.util.concurrent.CopyOnWriteArrayList"><value>http://serverA/simple</value><value>http://serverB/simple</value><value>http://serverC/simple</value><value>http://serverD/simple</value>
</util:list>
@Service
@ManagedResource
public class AlternateAddressesManager {@Resourceprivate List alternateAddresses;@ManagedOperationpublic void addAlternateAddress(String address) {alternateAddresses.add(address);}@ManagedOperationpublic boolean removeAlternateAddress(String address) {return alternateAddresses.remove(address);}@ManagedAttributepublic List getAlternateAddresses() {return Collections.unmodifiableList(alternateAddresses);}}
![](https://4.bp.blogspot.com/-SU0gJJbxh7o/Tes1xEIHXqI/AAAAAAAAACg/WFSLPedsKQg/s320/zrzut_ekranu-8.png)
![](https://2.bp.blogspot.com/--fF1igPMkdk/Tes11xfR4UI/AAAAAAAAACk/IVDuEN4MJcc/s320/zrzut_ekranu-9.png)
<bean id="testServiceClientFactoryBean" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean"><property name="serviceClass" value="com.blogspot.nurkiewicz.cxfcluster.SimpleService"/><property name="features"><util:list><bean class="org.apache.cxf.clustering.LoadDistributorFeature"><property name="strategy"><bean class="org.apache.cxf.clustering.SequentialStrategy"><property name="alternateAddresses" ref="alternateAddresses"/></bean></property></bean></util:list></property>
</bean><bean id="testServiceClientTarget" factory-bean="testServiceClientFactoryBean" factory-method="create" scope="prototype" lazy-init="true"/><bean id="testServiceClient" class="org.springframework.aop.framework.ProxyFactoryBean"><property name="targetSource"><bean class="org.springframework.aop.target.CommonsPoolTargetSource"><property name="targetClass" value="com.blogspot.nurkiewicz.cxfcluster.SimpleService"/><property name="targetBeanName" value="testServiceClientTarget"/><property name="maxSize" value="10"/><property name="maxWait" value="5000"/></bean></property>
</bean>
import org.apache.commons.pool.ObjectPool;
import org.apache.commons.pool.PoolUtils;
import org.springframework.aop.target.CommonsPoolTargetSource;public class SynchCommonsPoolTargetSource extends CommonsPoolTargetSource {@Overrideprotected ObjectPool createObjectPool() {return PoolUtils.synchronizedPool(super.createObjectPool());}}
参考: NoBlogDefFound博客上的 JCG合作伙伴 Tomasz 在Apache CXF中启用负载平衡和故障转移 。
- 具有Spring和Maven教程的JAX–WS
- Spring 3 RESTful Web服务
- Tomcat 7上具有RESTeasy JAX-RS的RESTful Web服务– Eclipse和Maven项目
翻译自: https://www.javacodegeeks.com/2011/06/apache-cxf-load-balancing-failover.html
apache cxf
apache cxf_Apache CXF负载平衡和故障转移相关推荐
- Apache CXF负载平衡和故障转移
前一段时间,我们已经面临基于Apache CXF的负载平衡Web服务客户端的需求. 此外,当某些服务器关闭时,客户端应自动进行故障转移. 更糟糕的是,服务器目标地址列表要从外部服务获取并在运行时更新. ...
- linux 双网卡绑定(bonding)实现负载均衡或故障转移
linux 双网卡绑定(bonding)实现负载均衡或故障转移 我们在这介绍的Linux双网卡绑定实现就是使用两块网卡虚拟成为一块网卡,这个聚合起来的设备看起来是一个单独的以太网接口设备,通俗点讲就是 ...
- 负载均衡和故障转移的使用案例
负载均衡和故障转移 文章目录 1)需求 2)需求分析 3)前期准备 4)配置文件 5)启动相关命令 6)检验 7)补充 1)需求 使用 Flume1 监控一个端口,其 sink 组中的 sink ...
- apache camel_使用Apache Camel进行负载平衡
apache camel 在此示例中,我们将向您展示如何使用Apache Camel作为系统的负载平衡器. 在计算机世界中,负载平衡器是一种充当反向代理并在许多服务器之间分配网络或应用程序流量的设备. ...
- 使用Apache Camel进行负载平衡
在此示例中,我们将向您展示如何使用Apache Camel作为系统的负载平衡器. 在计算机世界中,负载均衡器是一种充当反向代理并在许多服务器之间分配网络或应用程序流量的设备. 负载平衡器用于增加容量( ...
- camel_使用Apache Camel进行负载平衡
camel 在此示例中,我们将向您展示如何使用Apache Camel作为系统的负载平衡器. 在计算机世界中,负载平衡器是一种充当反向代理并在许多服务器之间分配网络或应用程序流量的设备. 负载平衡器用 ...
- 高并发应用场景下的负载均衡与故障转移实践,AgileEAS.NET SOA 负载均衡介绍与实践...
一.前言 AgileEAS.NET SOA 中间件平台是一款基于基于敏捷并行开发思想和Microsoft .Net构件(组件)开发技术而构建的一个快速开发应用平台.用于帮助中小型软件企业建立一条适合市 ...
- oracle查询报错clb,Oracle RAC 负载均衡与故障转移(三)
Server Service TAF https://www.cndba.cn/Breath/article/2324 服务端 service TAF 1.服务器端透明故障转移,通过配置service ...
- was连接oracle rac集群,Oracle 学习之RAC(九) 集群负载均衡及故障转移
查看监听,使用grid用户 11grac1:11grac1-> lsnrctl status LSNRCTL for Linux: Version 11.2.0.3.0 - Production ...
最新文章
- 安装envi出现cannot find lincese_Ubuntu 16.04 安装 CUDA10.1 (解决循环登陆的问题)
- 文件和存储管理学习笔记-动态磁盘管理
- java隋唐演义游戏下载_JAVA多线程
- python爬取json数据_Python爬取数据保存为Json格式的代码示例
- 设置phpMyAdmin连接本机已存在数据库
- excel手机版_手机自带便签如何导入新手机?试试这款便签同步助手
- UVA10341 Solve It【二分】
- 【图像配准】基于matlab GUI光流场模型医学图像配准【含Matlab源码 747期】
- 如何在vue中插入语音提示
- 130个资源网站,总有一个你用得着
- 【机器人学导论】 第二章.串联机器人
- 计算机时间与网络时间无法同步,终于解决了本地计算机时间无法与Internet时间服务器同步的难题...
- 如何把老旧笔记本变成一部 Chromebook
- 可ping通主机而不能连上主机端口的一般原因
- Easy Excel 使用总结
- java 面试知识点总结
- Java核心技术·卷二·第一章笔记
- 程序猿小白应该注意什么 1
- java邮件登录系统设计_基于Java web的邮件管理系统的设计与实现(含源文件).doc
- 正态分布检验:检验序列数据是否符合正态分布
热门文章
- 时间胶囊——给未来的留言板
- struts+hibernate+oracle+easyui实现lazyout组件的简单案例——工具类
- Android使用MPAndroidChat
- php 编写线程教程,php 实现多线程
- java 刷新界面_利用java如何实现在删除信息后刷新页面功能
- es6 dsl与sql对比
- mysql如何分析sql执行效率和进行效率优化
- 不相交集ADT(联机算法 + 脱机算法)
- 组装一台计算机 java_如何在同一台计算机上安装多个Java版本
- jsf el表达式_JSP,JSF和EL简介