1.3.1.1. Handle Cluster Restart

1.3.1.1. Handle Cluster Restart

We have covered the HA smart client architecture in Section 1.1.2.1, “Client-side interceptor”. The default HA smart proxy client can only failover as long as one node in the cluster exists. If there is a complete cluster shutdown, the proxy becomes orphanned and looses knowledge of the available nodes in the cluster. There is no way for the proxy to recover from this. The proxy needs to be looked up out of JNDI/HAJNDI when the nodes are restarted.

The 3.2.7+/4.0.2+ releases contain a RetryInterceptor that can be added to the proxy client side interceptor stack to allow for a transparent recovery from such a restart failure. To enable it for an EJB, setup an invoker-proxy-binding that includes the RetryInterceptor. Below is an example jboss.xml configuration.

<jboss>
    <session>
        <ejb-name>nextgen_RetryInterceptorStatelessSession</ejb-name>
        <invoker-bindings>
            <invoker>
                <invoker-proxy-binding-name>
                    clustered-retry-stateless-rmi-invoker
                </invoker-proxy-binding-name>
                <jndi-name>
                    nextgen_RetryInterceptorStatelessSession
                </jndi-name>
            </invoker>
        </invoker-bindings>
        <clustered>true</clustered>
    </session>

    <invoker-proxy-binding>
        <name>clustered-retry-stateless-rmi-invoker</name>
        <invoker-mbean>jboss:service=invoker,type=jrmpha</invoker-mbean>
        <proxy-factory>org.jboss.proxy.ejb.ProxyFactoryHA</proxy-factory>
        <proxy-factory-config>
            <client-interceptors>
                <home>
                    <interceptor>
                        org.jboss.proxy.ejb.HomeInterceptor
                    </interceptor>
                    <interceptor>
                        org.jboss.proxy.SecurityInterceptor
                    </interceptor>
                    <interceptor>
                        org.jboss.proxy.TransactionInterceptor
                    </interceptor>
                    <interceptor>
                        org.jboss.proxy.ejb.RetryInterceptor
                    </interceptor>
                    <interceptor>
                        org.jboss.invocation.InvokerInterceptor
                    </interceptor>
                </home>
                <bean>
                    <interceptor>
                        org.jboss.proxy.ejb.StatelessSessionInterceptor
                    </interceptor>
                    <interceptor>
                        org.jboss.proxy.SecurityInterceptor
                    </interceptor>
                    <interceptor>
                        org.jboss.proxy.TransactionInterceptor
                    </interceptor>
                    <interceptor>
                        org.jboss.proxy.ejb.RetryInterceptor
                    </interceptor>
                    <interceptor>
                        org.jboss.invocation.InvokerInterceptor
                    </interceptor>
                </bean>
            </client-interceptors>
        </proxy-factory-config>
    </invoker-proxy-binding>