2 Replies Latest reply on Mar 24, 2004 12:10 PM by Kevin Turner

    Load-Balancing in container

    Kevin Turner Newbie

      I'm running JBoss 3.2.3 with 2 nodes in the default partition. I have configured a stateless session bean for clustering (with the default RoundRobin load-balancing policy). When invoking the session bean from a client (outside of container JVM), the load-balancing works fine. Each call to the session bean alternates between nodes as expected. However, when invoking the methods on the same session bean from within a message-driven bean, the calls are not load-balanced.

      public void onMessage(Message message)
       MapMessage mapMessage = (MapMessage) message;
       String testMsg = mapMessage.getString("Test");
       InitialContext ctx = new InitialContext();
       TestSessionHome home = (TestSessionHome) PortableRemoteObject.narrow
       ( ctx.lookup ("TestSession"), TestSessionHome.class);
       TestSession session = home.create();
       session.test(testMsg + "A");
       session.test(testMsg + "B");
       catch (Exception e)

      The session bean simply logs the message to the System.out. Both A and B messages are always processed by the same node. I would have expected one node to process message "A" while the other node processes message "B".

      Is it possible to have load-balanced session bean calls within the container? I've read thru the JBoss clustering documentation a few times and didn't find any solutions. Thanks in advance for the help.

        • 1. Re: Load-Balancing in container
          Sacha Labourey Master

          This is per-design: when the target is available in the same JVM as the client, we by-pass the remoting layers and do a direct Java call, hence by-passing the load-balancing layers as well.



          • 2. Re: Load-Balancing in container
            Kevin Turner Newbie

            Sasha, thanks for the reply.

            Hopefully, there is a work-around for this. My process will generate work units to enable concurrent processing. For each work unit, I will send a JMS message which will be processed by a Message-Driven Bean. The Message-Driven Bean will then invoke the clustered Session Bean to do the work. I would like for this work to be distributed among the nodes for performance reasons. Based on your reply, it sounds like this is not possible. Please let me know if there is a work-around or a better approach.

            Kevin Turner
            ACTEK, Inc.