7 Replies Latest reply on Jun 18, 2013 4:34 AM by jahoshai

    Failover for clustered EJBs not working

    jahoshai

      I am working on EJB clustering on jboss EAP 6.0.1

      I have cluster of two nodes running on ha-full profile.

       

      When doing remote client to server invocations, fail over is not happening.

      Once I bring down the node that is serving the requests,the subsequent request fail with "No EJB Reciever" error.

       

      I have my EJBs annotated with @Clustered.

       

      I can see ejb clustering happening from my server log

       

      [Server:server-three] 16:26:15,916 INFO  [org.jboss.as.clustering] (Incoming-9,shared=udp) JBAS010225: New cluster view for partition ejb (id: 3, delta: 1, merge: false) : [master:server-three/ejb, slave:server-three-slave/ejb]
      

       

      In the jboss-ejb-client.properties I have added remote clusters

       

       

      endpoint.name=client-endpoint
      remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
      
      remote.connections=default
      remote.connection.default.host=10.106.8.73
      remote.connection.default.port = 4447
      remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
      remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT=false
      
      remote.connection.default.username=superadmin
      remote.connection.default.password=superadmin
      
       remote.clusters=ejb
      remote.cluster.ejb.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
      remote.cluster.ejb.connect.options.org.xnio.Options.SSL_ENABLED=false
      remote.cluster.ejb.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT=false
      

       

      My client code is

       

      public class RemoteHelper
      {
          
          private static Context ctx;
      
          private static Context getContext() throws Exception
          {
      
              if (ctx == null)
              {
              
                  Hashtable<Object, Object> ht = new Hashtable<Object, Object>();
                  ht.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
                  
                  ctx = new InitialContext(ht);
              }
      
              return ctx;
          }
      
      
      
          public static Object getRemoteBean(String beanName)
          {
              Object obj;
              try
              {
                  beanName = "ejb:myApp/platform-ejb//"+beanName.split("#")[0]+"!"+beanName.split("#")[1];
                  
                  obj = getContext().lookup(beanName);
                  
              }
              catch (Exception e)
              {
                  throw new RuntimeException(e);
              }
              return obj;
          }
      
      }
      

      I have JUnit test which makes the invocations.

       

      public class RemoteServiceManagementTest
      {
          private static ServiceManagement serviceManagement;
        
      
          @BeforeClass
          public static void init()
          {
              try
              {
                   serviceManagement = (ServiceManagement) RemoteHelper
                          .getRemoteBean("ServiceManagement#com.app.core.servicemanagement.registry.service.RemoteServiceManagement");
                  
              }
              catch (Exception e)
              {
                  throw new RuntimeException(e);
              }
          }
      
          @Test
          public void testGetService()
          {
              int count=1;
              while(count<200){
                  try{
                      Service service = serviceManagement.getServiceByName("REMOTE_SERVICE01001");
                     }
                  catch(Exception e){
                      System.out.println("error: "+e.getMessage());
                  }
                  
              }
                      
          }
      
      }
      

       

      This is how my EJB3 subsystem looks

       

      <subsystem xmlns="urn:jboss:domain:ejb3:1.3">
                      <session-bean>
                          <stateless>
                              <bean-instance-pool-ref pool-name="slsb-strict-max-pool"/>
                          </stateless>
                          <stateful default-access-timeout="5000" cache-ref="simple" clustered-cache-ref="clustered"/>
                          <singleton default-access-timeout="5000"/>
                      </session-bean>
                      <mdb>
                          <resource-adapter-ref resource-adapter-name="hornetq-ra"/>
                          <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>
                      </mdb>
                      <pools>
                          <bean-instance-pools>
                              <strict-max-pool name="slsb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>
                              <strict-max-pool name="mdb-strict-max-pool" max-pool-size="20" instance-acquisition-timeout="5" instance-acquisition-timeout-unit="MINUTES"/>
                          </bean-instance-pools>
                      </pools>
                      <caches>
                          <cache name="simple" aliases="NoPassivationCache"/>
                          <cache name="passivating" passivation-store-ref="file" aliases="SimpleStatefulCache"/>
                          <cache name="clustered" passivation-store-ref="infinispan" aliases="StatefulTreeCache"/>
                      </caches>
                      <passivation-stores>
                          <file-passivation-store name="file"/>
                          <cluster-passivation-store name="infinispan" cache-container="ejb"/>
                      </passivation-stores>
                      <async thread-pool-name="default"/>
                      <timer-service thread-pool-name="default">
                          <data-store path="timer-service-data" relative-to="jboss.server.data.dir"/>
                      </timer-service>
                      <remote connector-ref="remoting-connector" thread-pool-name="default"/>
                      <thread-pools>
                          <thread-pool name="default">
                              <max-threads count="10"/>
                              <keepalive-time time="100" unit="milliseconds"/>
                          </thread-pool>
                      </thread-pools>
                      <iiop enable-by-default="false" use-qualified-name="false"/>
                  </subsystem>
      

       

      My Infinispan subsystem

       

                  <subsystem xmlns="urn:jboss:domain:infinispan:1.3">
                      <cache-container name="cluster" aliases="ha-partition" default-cache="default">
                          <transport lock-timeout="60000"/>
                          <replicated-cache name="default" mode="SYNC" batching="true">
                              <locking isolation="REPEATABLE_READ"/>
                          </replicated-cache>
                      </cache-container>
                      <cache-container name="web" aliases="standard-session-cache" default-cache="repl" module="org.jboss.as.clustering.web.infinispan">
                          <transport lock-timeout="60000"/>
                          <replicated-cache name="repl" mode="ASYNC" batching="true">
                              <file-store/>
                          </replicated-cache>
                          <replicated-cache name="sso" mode="SYNC" batching="true"/>
                          <distributed-cache name="dist" l1-lifespan="0" mode="ASYNC" batching="true">
                              <file-store/>
                          </distributed-cache>
                      </cache-container>
                      <cache-container name="ejb" aliases="sfsb sfsb-cache" default-cache="repl" module="org.jboss.as.clustering.ejb3.infinispan">
                          <transport lock-timeout="60000"/>
                          <replicated-cache name="repl" mode="ASYNC" batching="true">
                              <eviction strategy="LRU" max-entries="10000"/>
                              <file-store/>
                          </replicated-cache>
                          <replicated-cache name="remote-connector-client-mappings" mode="SYNC" batching="true"/>
                          <distributed-cache name="dist" l1-lifespan="0" mode="ASYNC" batching="true">
                              <eviction strategy="LRU" max-entries="10000"/>
                              <file-store/>
                          </distributed-cache>
                      </cache-container>
                      <cache-container name="hibernate" default-cache="local-query" module="org.jboss.as.jpa.hibernate:4">
                          <transport lock-timeout="60000"/>
                          <local-cache name="local-query">
                              <transaction mode="NONE"/>
                              <eviction strategy="LRU" max-entries="10000"/>
                              <expiration max-idle="100000"/>
                          </local-cache>
                          <invalidation-cache name="entity" mode="SYNC">
                              <transaction mode="NON_XA"/>
                              <eviction strategy="LRU" max-entries="10000"/>
                              <expiration max-idle="100000"/>
                          </invalidation-cache>
                          <replicated-cache name="timestamps" mode="ASYNC">
                              <transaction mode="NONE"/>
                              <eviction strategy="NONE"/>
                          </replicated-cache>
                      </cache-container>
                  </subsystem>
      

       

      I just doubht whether the client is recieving the cluster topology information from the server.

      Am I missing any configuration here.

      Please help me in resolving this issue.

      Thankyou in advance.