2 Replies Latest reply on Jul 4, 2007 7:26 AM by chapata_gunner

    @Clustered! How to check if its working?

    chapata_gunner

      I have a bean which has been defined as follows.

      @Stateless
      @Clustered
      public class StatelessCalculatorBean implements Calculator {
      
       public double calculate(int start, int end, double growthrate, double saving) {
       double tmp = Math.pow(1. + growthrate / 12., 12. * (end - start) + 1);
       return saving * 12. * (tmp - 1) / growthrate;
       }
      
      }
      


      This is the bean interface.
      @Remote
      public interface Calculator {
      
       public double calculate(int start, int end, double growthrate, double saving);
      
      }
      


      This EJB is deployed on two JBoss 4.2.0GA servers (running on different machines with 'all' domain).

      Now I lookup this EJB in a Servlet and call the calculate method on it 4 times.
       Properties p = new Properties();
       p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
       p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
       p.put(Context.PROVIDER_URL, "actual ip_01:1100,actual ip_02:1100");
       InitialContext ctx = new InitialContext(p);
       cal = (Calculator) ctx.lookup("StatelessCalculatorBean/remote");
       cal.calculate(25, 65, 0.08, 300.0);
       cal.calculate(35, 75, 0.08, 300.0);
       cal.calculate(45, 85, 0.08, 300.0);
       cal.calculate(55, 95, 0.08, 300.0);
      


      Now I want 2 of these calls to hit ip_01 and 2 calls to hit ip_02 in a RoundRobin way...which is the default for @Clustered in SLSB (as per the wiki).

      Can anyone tell me what I am doing wrong here? For some reason only the EJB from ip_01 is being called for all 4 instances.
      The Servlet is present only on the ip_01 machine.

      Any help will be greatly appreciated!


        • 1. Re: @Clustered! How to check if its working?
          chapata_gunner

          Did a little more research...

          If i put the code that I used to put in a Servlet inside a normal Java file and execute it ... Everything works properly. So it seems that in order for LoadBalancing to work properly we need to execute the calls from a separate JVM. Is that correct?

          Can anyone please confirm it?

          Also is there any way to move past this restriction?

          • 2. Re: @Clustered! How to check if its working?
            chapata_gunner

            OK! Finally found a solution to my problem :)

            JBoss 'all' domain comes with certain AOP interceptors for EJB3. Of these the IsLocalInterceptor and ClusteredIsLocalInterceptor were creating all this fuss. I just disabled them and everything works fine.