1 Reply Latest reply on Oct 19, 2010 7:47 AM by wdfink

    JBoss 5.0.0 failover

    vladimir_kiryakov

      Hi

      Please can any body help me...

      I run 2 nodes in cluster mode. On which of them i will deployed simple stateless bean:

       

      import javax.ejb.Stateless;

       

      import org.jboss.ejb3.annotation.Clustered;

       

      /** Session Bean implementation class MasterBean */
      @Stateless
      @Clustered
      public class MasterBean implements IMasterBeanRemote {

       

          /** Default constructor. */
          public MasterBean() { }

       

          @Override
          public void show() {

              int __counter = 1;

              while(true) {          
                  try {
                      Thread.sleep(1000);
                      System.out.println(__counter++);
                  } catch (Exception e) { e.printStackTrace(); }
              }
          }

      }

       

      This is client

       

      package pckg;

       

      import java.util.Properties;

       

      import javax.naming.Context;
      import javax.naming.InitialContext;

       

      import bean.pckg.IMasterBeanRemote;
      import bean.pckg.MasterBean;

       

      public class MainCLass {

       

          /**
           * @param args
           */
          public static void main(String[] args) throws Exception {
              System.out.println("start");
              while(true) {
                  Properties __connectUtils = new Properties();
                  __connectUtils.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
                  __connectUtils.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
                  __connectUtils.put(Context.PROVIDER_URL, "jnp://10.38.62.15:1100,10.38.62.151:1100");
                  Context __ctx = new InitialContext(__connectUtils);

       

                  IMasterBeanRemote __iRemote = (IMasterBeanRemote) __ctx.lookup(MasterBean.class.getSimpleName() + "/remote");
                  __iRemote.show();
              }
          }

       

      }

       

      Application is launched on 15th node when I kill her, application is launched on 151st node. But when I again launch 15th and I kill 151st it turns out exception(Can not get connection to server bla bla bla). How to force application to understand that 15th node is already launched?

        • 1. Re: JBoss 5.0.0 failover
          wdfink

          What you wrote is a endless loop in your SLSB on the server!

           

          Failover mean NOT that a call move to another server!

          A running call will fail if this note hung up or crash.

           

          expand your show method to show(String text) { System.out.println(text); }

          Move the loop to your main() and cover __IRemote.show()

           

          If you start the JBoss instances you should see something like 'Number of new mebers :1 / Number of other members 1' in your JBoss logfiles if the cluster is configured correct.

           

          If you start your main() the show call should balanced over both nodes and in case of kill or shutdown one all calls will run to the single one.