Env : Spring Framework 3.2.3.RELEASE
簡単なスプリング コンテキスト構成でフェイルオーバーを実現する方法はありRmiProxyFactoryBean
ますか?
ServerA をプライマリとして、ServerB を代替 RMI サーバーとして使用しています。ServerA への接続がダウンしている場合、RMI 呼び出しは ServerB に向けられる必要があります。
Env : Spring Framework 3.2.3.RELEASE
簡単なスプリング コンテキスト構成でフェイルオーバーを実現する方法はありRmiProxyFactoryBean
ますか?
ServerA をプライマリとして、ServerB を代替 RMI サーバーとして使用しています。ServerA への接続がダウンしている場合、RMI 呼び出しは ServerB に向けられる必要があります。
このフェールオーバー スイッチングを実現する方法をオーバーライドしrefreshAndRetry
ました。lookupStub
RMIProxyFactoryBean
@Override
protected Object refreshAndRetry(MethodInvocation invocation) throws Throwable {
if (logger.isDebugEnabled()) {
logger.debug("Refreshing & retrying remote invocation.");
}
swapHitURLs();//Swap primary<>secondary URL
return super.refreshAndRetry(invocation);
}
@Override
protected Remote lookupStub() throws RemoteLookupFailureException {
Remote stub=null;
if (logger.isDebugEnabled()) {
logger.debug("Looking up the stub.");
}
try{
stub=super.lookupStub();
}catch(RemoteLookupFailureException rlfx){
swapHitURLs();//Swap primary<>secondary URL
if (logger.isDebugEnabled()) {
logger.debug("Looking up the stub for swapped URL.");
}
stub=super.lookupStub();
}
return stub;
}
構成 XML:
<bean id="beanName" class="com.ahamed.poc.rmi.FailOverRMIProxyFactory" lazy-init="true">
<property name="serviceUrl" value="PrimaryURL"/>
<property name="alternativeServiceUrl" value="SecondaryURL"/>
<property name="serviceInterface" value="com.ahamed.poc.rmi.InterfaceClass"/>
</bean>
より良いオプションがあれば教えてください。