2 Replies Latest reply on Aug 31, 2005 4:28 PM by jason1

    Clustered servers on same machine not load-balancing

    jason1 Newbie

      In several places on the Forum and Wiki (ex: http://www.jboss.com/index.html?module=bb&op=viewtopic&t=52323)
      I see that I can run a cluster on the same machine (same NIC too). I've set it up using the binding service and it works great UNTIL testing load-balancing of requests across a clustered SLSB. They simply go to the same EJB each time. Any ideas?

      Here is some JGroups logging which tells me they see each other:
      GMS: address is tocarbong1:2535
      12:57:48,612 INFO [TreeCache] viewAccepted(): new members: [tocarbong1:1108, tocarbong1:2535]

      GMS: address is tocarbong1:1108
      12:57:48,628 INFO [TreeCache] viewAccepted(): new members: [tocarbong1:1108, tocarbong1:2535]

      My JUnit looks like this:

       * Calls ping on the same referenced Delegate SLSB
       * Tests RoundRobin load-balancing policy
       * @throws Exception
      public void testPingClusteredSameEJB() throws Exception {
       String curr;
       String prev = "!!!!!";
       // Uses direct EJB lookup rather than ServiceLocator
       InitialContext ic = new InitialContext();
       Object object = ic.lookup(DelegateSLSBeanRemoteHome.JNDI_NAME);
       DelegateSLSBeanRemoteHome home = (DelegateSLSBeanRemoteHome)PortableRemoteObject.narrow(object, DelegateSLSBeanRemoteHome.class);
      DelegateSLSBeanRemote delegateSLSB = home.create();
       for (int i=1;i<=10;i++){
       // returns unique name of each JBoss server
       Object pingReturn = delegateSLSB.ping();
       curr = pingReturn.toString();
       if (i>1 && curr.equals(prev)) {
       fail("RoundRobin failed. Ping to the same EJB references contacted the same servers in the cluster");
       prev = curr;