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>