您的位置:首页 > 编程语言 > Java开发

Spring RMI 配置和使用以及带均衡策略时client端的配置

2014-08-20 14:18 447 查看
client端:

a.不带均衡策略

<bean id="galaxyReportRemoteInterface_0" class="org.springframework.remoting.rmi.RmiProxyFactoryBean" lazy-init="true">

<property name="serviceUrl"><value>${rmi.report1}</value></property>

<property name="serviceInterface" value="com.sogou.earth.web.report.rmi.GalaxyReportRemoteInterface"></property>

<property name="lookupStubOnStartup" value="false"/>

<property name="refreshStubOnConnectFailure" value="true"/>

<property name="registryClientSocketFactory" ref="rmiSocketFactory" />

</bean>

<bean id="rmiSocketFactory" class="net.sf.ehcache.distribution.ConfigurableRMIClientSocketFactory">

<constructor-arg index="0"><value>${rmi.timeout}</value></constructor-arg>

</bean>

b.带均衡策略(RoundRobinStrategy 轮循)

<bean id="galaxyReportRemoteInterfaceSelector" class="com.sogou.earth.web.report.rmi.GalaxyReportRemoteInterfaceSelectorImpl" lazy-init="true">

<property name="rmiSelectStrategy" ref="rmiSelectStrategy"></property>

<property name="targets">

<map>

<entry key="galaxyReportRemoteInterface_0" value-ref="galaxyReportRemoteInterface_0"/>

<entry key="galaxyReportRemoteInterface_1" value-ref="galaxyReportRemoteInterface_1"/>

</map>

</property>

</bean>

<bean id="rmiSelectStrategy" class="com.sogou.earth.web.report.rmi.RoundRobinStrategy" lazy-init="true">

<constructor-arg>

<map key-type="java.lang.String" value-type="java.lang.Integer">

<entry key="galaxyReportRemoteInterface_0" value="1" />

<entry key="galaxyReportRemoteInterface_1" value="1" />

</map>

</constructor-arg>

</bean>

<bean id="galaxyReportRemoteInterface_0" class="org.springframework.remoting.rmi.RmiProxyFactoryBean" lazy-init="true">

<property name="serviceUrl"><value>${rmi.report1}</value></property>

<property name="serviceInterface" value="com.sogou.earth.web.report.rmi.GalaxyReportRemoteInterface"></property>

<property name="lookupStubOnStartup" value="false"/>

<property name="refreshStubOnConnectFailure" value="true"/>

<property name="registryClientSocketFactory" ref="rmiSocketFactory" />

</bean>

<bean id="galaxyReportRemoteInterface_1" class="org.springframework.remoting.rmi.RmiProxyFactoryBean" lazy-init="true">

<property name="serviceUrl"><value>${rmi.report2}</value></property>

<property name="serviceInterface" value="com.sogou.earth.web.report.rmi.GalaxyReportRemoteInterface"></property>

<property name="lookupStubOnStartup" value="false"/>

<property name="refreshStubOnConnectFailure" value="true"/>

<property name="registryClientSocketFactory" ref="rmiSocketFactory" />

</bean>

<bean id="rmiSocketFactory" class="net.sf.ehcache.distribution.ConfigurableRMIClientSocketFactory">

<constructor-arg index="0"><value>${rmi.timeout}</value></constructor-arg>

</bean>

服务端:

<bean id="galaxyReportRemoteInterface" class="com.sogou.galaxy.report.rmi.GalaxyReportRemoteInterfaceImpl" autowire="byName" />

<bean class="org.springframework.remoting.rmi.RmiServiceExporter">

<property name="serviceName" value="galaxyReportRemoteInterface"></property>

<property name="service">

<ref local="galaxyReportRemoteInterface"/>

</property>

<property name="serviceInterface" value="com.sogou.earth.web.report.rmi.GalaxyReportRemoteInterface">

</property>

<property name="registryPort"><value>${rmi.stub.business.port}</value></property>

</bean>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐