3 Replies Latest reply on Jan 9, 2004 9:19 AM by jmspaggi

    Clustering + Client Threads

    pauloh

      Hi everybody,

      I'm trying to use Clustering but I'm running into some problems. I use jboss-3.0.3 with tomcat-4.1.12 and the default configuration for clistering and farming. I'm using HA-JNDI as well.

      What I'm doing:

      Just after I call the create() of my EJB (Stateless Session EJB), I start several threads, each one calling once the remote method of the EJB. I mean: 1 call to create() then several calls to remoteMethod() in separate threads.


      The problem is:

      When I do it from a standalone Java client for the EJB, it works fine and I can see the RoundRobin. But when I do it from a Servlet, only one JBoss server is called (the same that runs the Servlet), that is, the cluster doesn't work properly.

      Any idea why??? Is there a solution for this? (I can't use a standalone client)

      I'm sending some source code below...

      Thanks in advance!
      Regards,

      Paulo


      --------- Source Code ------------

      /**
      * Method that creates and calls the EJB
      */
      protected void runJob() throws Exception
      {
      ComparisonProcessSrvMgrHome testComparisonBean = null;

      //Look up home interface
      try {
      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,
      "schindler:1100,ubatuba:1100");

      InitialContext ctx = new InitialContext(p);

      Object objrefComparison = ctx.lookup("ejb/com/cpqd/billing/recon/business/services/comparison/ComparisonProcessSrvMgrBean");

      testComparisonBean = (ComparisonProcessSrvMgrHome) PortableRemoteObject.narrow(objrefComparison,ComparisonProcessSrvMgrHome.class);

      }
      catch (Exception e) {
      e.printStackTrace();
      }

      final ComparisonProcessSrvMgr comparisonBeanRemote =
      testComparisonBean.create();

      for (int i = 0; i < 100; i++) {

      final int count = i;

      new Thread() {
      public void run() {
      try {
      comparisonBeanRemote.businessMethod(count);
      }
      catch (Exception e) {
      e.printStackTrace();
      }
      }
      }.start();
      }
      }

        • 1. Re: Clustering + Client Threads
          slaboure

          As the proxy detects that the servlet engine is in the same JVM as the target EJB, it makes an optimized local call instead of a remote call, that is a feature, not a problem.

          Cheers,


          sacha

          • 2. Re: Clustering + Client Threads
            luciano

            Sacha, (you just emailed me about this topic, thanks)

            what if I want to distribute the load of a long process between all machines in my cluster, including the one that´s starting the process?
            Should I have two instances of JBoss in one machine just to do that?

            Thanks
            Luciano

            • 3. Re: Clustering + Client Threads
              jmspaggi

              slaboure, do you think it is possible to disable this "feature" ? For all classes, or maybe only for only one ?

              Because at this time, I need to have on other tomcat running in another JVM on the same computer, only for bypass this "feature" :(

              JMS.