2 Replies Latest reply on Feb 14, 2005 8:58 PM by Keyur Shah

    EJB 3.0 clustered SFSB: load balancing works, fail over does

    Keyur Shah Newbie

      Consider this simple example:

      @Stateful
      @org.jboss.ejb3.remoting.Clustered
      public class SFSBClusterBean implements SFSBCluster, Serializable {
      
       transient String state = null;
       String dto = null;
       transient boolean modified = false;
      
       public String getState() {
       System.out.println("getState");
       return state;
       }
      
       public void updateState(String newState) {
       System.out.println("updateState");
       state = newState;
       modified = true;
       }
      
       @PrePassivate public void passivate() {
       System.out.println("passivate");
       dto = state;
       state = null;
       modified = false;
       }
      
       @PostActivate public void activate() {
       System.out.println("activate");
       state = dto;
       dto = null;
       modified = false;
       }
      
       public boolean isModified() {
       System.out.println("isModified");
       return modified;
       }
      
      }
      


      I have setup a cluster with 2 nodes... When I run multiple clients, it load balances well... However, when I shutdown one of the nodes, the clients accessing that node also die...

      I built a similar example in EJB 2.1 and it load balances as well as fails over correctly.

      One difference I noted was that while the EJB 2.1 bean's isModified() was called (and subsequently, ejbPassivate() if the bean was modified) after every client method call, the isModified() method is never called for EJB3 (and so by extension neither is the passivate() method called).

      A bug or am I doing something wrong?