2 Replies Latest reply on Dec 6, 2002 12:17 PM by jaksa

    SFSB state replication

      Hi.
      I'm Having some problems in making SFSB clustering work. I'm using the 3.0.3 version in the "all" configuration. I have two JBoss instances running on 2 machines. The instances are able to see eachother.
      I have implemented a SFSB called counter which has 2 methods increase() and getValue(). I access this bean from a java client via RMI which calls the increase method 1000 times.
      I deployed the bean on both servers and I have configured the bean-load-balance-policy to RoundRobin.
      The call redirection seems to work fine, but state does not get transfered. In other words I get 499 calls on one server and 501 on the other but both the counters show the values 499 and 501 instead of 1000. Is it supposed to work this way or do I have to configure the server to do Stateful Bean Replication? Or maybe I did something wrong when implementing the bean. I have modified the jboss.xml deployment descriptor, do I have to specify somewhere else that the bean is clustered?

      Jaksa

      Here you are some snippets of the code:


      ***************************
      jboss.xml:
      ***************************
      ...

      <ejb-name>clustered/Counter</ejb-name>
      <jndi-name>ejb/clustered/Counter</jndi-name>
      True
      <cluster-config>
      <partition-name>DefaultPartition</partition-name>
      <home-load-balance-policy>org.jboss.ha.framework.interfaces.RoundRobin</home-load-balance-policy>
      <bean-load-balance-policy>org.jboss.ha.framework.interfaces.RoundRobin</bean-load-balance-policy>
      <session-state-manager-jndi-name>/HASessionState/Default</session-state-manager-jndi-name>
      </cluster-config>

      ...


      ***************************
      CounterBean.java:
      ***************************
      ...
      public class CounterBean implements SessionBean {
      public int value;

      public int getValue() { return this.value; }

      public void increase() {
      this.value++;
      System.out.println("counter: " + this.value);
      }

      public void ejbCreate() { this.value = 0; }
      public void ejbActivate() {}
      public void ejbPassivate() {}
      public void ejbRemove() {}
      public void setSessionContext(SessionContext parm1) {}
      }


      ***************************
      ClusteredClient.java:
      ***************************
      ...
      InitialContext ctx = new InitialContext();
      Object objref = ctx.lookup("ejb/clustered/Counter");
      CounterHome counterHome = (CounterHome)PortableRemoteObject.narrow(objref, CounterHome.class);

      // create the bean
      Counter counter = counterHome.create();

      // invoke some methods
      for (int i=0; i<1000; i++) {
      counter.increase();
      }
      ...