2 Replies Latest reply on Aug 1, 2013 3:29 AM by balap6

    EJBClient Reconnect Issue with Cluster Node Selector

    balap6 Newbie

      Hi

       

      I am trying for EJB Client reconnect option with standalone client after  JBoss App restart.

       

      Version:-JBoss EAP 6.1 Alpha

       

      Steps:

      1. Deployed TestRemote EJB in two App server(App1 & App2) in ejb cluster

      2. Started App1 & App2

      3. Started EjbClient in standalone program

      4. So the loaded is balance based AllClusterNodeSelector between App1 & App2 (AllClusterNodeSelector is from ejb client sample program).

      5. Stopped App1 and started tge App1.

      6. Then all the request is going to App2  and load is not divided between two servers.

      7. Once it restart the EjbClient Program, then it load balancing the request to both server

       

      Please let me know whether i am missing some thing / its issue in Jboss

       

       

      Please find my sample EjbClient standalone program

       

      Program:-

      private static ITestRemote lookup()

                  throws NamingException {

              final Hashtable<String, Object> jndiProps = new Hashtable<String, Object>();

              jndiProps.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");

                  final Context context = new InitialContext(jndiProps);

              String lookupName = "ejb:APP/APPEngine/TestRemote!com.service.ITestRemote";

              System.out.println("lookupName=" + lookupName);

       

              ITestRemote te = (ITestRemote) context.lookup(lookupName);

              return te;

          }

       

      public static void createClusterEJBClientContext(String clusterName, int port,  String... ipAddress) {

              StringBuilder sb = new StringBuilder();

              for (int i = 0; i < ipAddress.length; i++) {

                  sb.append(APP_SERVER).append(i).append(",");

              }

              sb.deleteCharAt(sb.length() - 1);

              String serverNameList = sb.toString();

              Properties properties = new Properties();

              properties.put("remote.connections", serverNameList);

              properties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED","false");

       

              for (int i = 0; i < ipAddress.length; i++) {

                  properties.put("remote.connection." + APP_SERVER + i + ".connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS", "JBOSS-LOCAL-USER");

                  properties.put("remote.connection." + APP_SERVER + i + ".connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");

                  properties.put("remote.connection." + APP_SERVER + i + ".host",ipAddress[i].trim());

                  properties.put("remote.connection." + APP_SERVER + i + ".port",String.valueOf(port));

                  properties.put("remote.connection." + APP_SERVER + i + ".username","abcdef");

                  properties.put("remote.connection." + APP_SERVER + i + ".password","abc@123");

              }

             

              properties.put("invocation.timeout", "3000");

              properties.put("reconnect.tasks.timeout", "2000");

             

              properties.put("remote.clusters", clusterName);

              properties.put("remote.cluster."+clusterName+".connect.options.org.xnio.Options.SSL_ENABLED", "false");

              properties.put("remote.cluster."+clusterName+".connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");

              properties.put("remote.cluster."+clusterName+".connect.options.org.xnio.Options.SASL_DISALLOWED_MECHANISMS", "JBOSS-LOCAL-USER");

              properties.put("clusternode.selector", AllClusterNodeSelector.class.getName());

             

              EJBClientConfiguration ejbClientConf = new PropertiesBasedEJBClientConfiguration(properties);

              ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(ejbClientConf);

              EJBClientContext.setSelector(selector);

           

          }

          

          

      public static void main(String[] args) {

              try {

                  createClusterEJBClientContext();

                   for(int i=1;i<1000;i++){

                       try{

                           Thread.sleep(1000l);

                       }catch(Exception e){

                           e.printStackTrace();

                       }

                       ITestRemote testRemote1 = lookup();

                       try{

                       System.out.println(testRemote1.print("Test ="+i));

                       }catch(Exception e){

                           e.printStackTrace();

                       }

                   }

              } catch (NamingException e) {

                  e.printStackTrace();

              }

       

          }

       

       

       

      Thanks,

      Balaji Prasath