2 Replies Latest reply on Oct 2, 2009 6:12 PM by Roman Mandeleil


    Roman Mandeleil Newbie


      I try to cook load balancing through JMS connection factory here is two questions to the pros:

      1) When I use it from the stand alone it really works, which means it creates connection to each node in it's turn. The question is when I get the object - JBossConnectionFactory I see it encapsulates ClientClusteredConnectionFactoryDelegate object which is reasonable but the data member supportLoadBalancing is false, the question is why ?

      2) The second question is when I try the same stuff not from the stand alone to a server but from server to server it doesn't work the connection been created each time to one node despite the fact there is two nodes in the cluster, again the question is what can be the problem ?

      Here is all the details:

      I am using JBoss 5.1 GA all - configuration, two nodes - ports binding 02 and 03.

      on the client here is the code that gets the factory and creates the connection:

       Connection connection = null;
       InitialContext initialContext = null;
       Hashtable<String, String> jndiParameters = new Hashtable<String, String>();
       jndiParameters.put("java.naming.provider.url", ",");
       jndiParameters.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
       jndiParameters.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
       initialContext = new InitialContext(jndiParameters);
       Queue queue = (Queue) initialContext.lookup("/queue/DLQ");
       ConnectionFactory cf = (ConnectionFactory) initialContext
       for (Integer i = 0; true; i++) {
       try {
       connection = cf.createConnection();
       Session session = connection.createSession(false,
       MessageProducer producer = session.createProducer(queue);
       String myString = new String(i.toString());
       ObjectMessage objectMessage = session.createObjectMessage(myString);
       } catch (Throwable th){
       } finally {
       if (connection != null) {

      on the server I use the same principle.

      Thanks in advance

        • 1. Re: ClusteredConnectionFactory
          Clebert Suconic Master

          If you are inside the server, it will always connect to that same server.

          You can enable load balancing on the CF used by the Resource Adapter, but it would become a mess.

          As you have MDBs and other Beans, you will have other things controlling balancing for you. For instance as you get traffic on nodeA on a HTTPServer, you use most of the load on that node. If you mix up load balancing on the server side you will actually hurt performance instead.

          • 2. Re: ClusteredConnectionFactory
            Roman Mandeleil Newbie

            I think I am over that issue, the problem was that when I look-up from the server to ClusterConnectionFactory it actually gives me the local instance and it doesn't matter what addresses been mentioned in the java.naming.provider.url.

            So I have solved that problem by creating another CF on the distant cluster with different JNDI binding.