2 Replies Latest reply on Feb 27, 2012 4:44 AM by Muthukumaran Manickavasagam

    HornetQ load balancing issue

    Muthukumaran Manickavasagam Newbie



      I'm trying to workaround the failure over issue discussed at (https://community.jboss.org/message/717017#717017). This is what i have i'm trying,


      1) So far i'm using JNDI and i have changed it, not to use JNDI but creating the QConnectionFactory directly. See my sample code,



      Map<String, Object> connectionParams = new HashMap<String, Object>();

      connectionParams.put(TransportConstants.PORT_PROP_NAME, 5455);


      TransportConfiguration tc = new TransportConfiguration(NettyConnectorFactory.class.getName(), connectionParams);

      ServerLocator sl = new ServerLocatorImpl(true, tc);


      QueueConnectionFactory connectionFactory = (QueueConnectionFactory)new HornetQJMSConnectionFactory(sl);

      queueConnection = connectionFactory.createQueueConnection("guest", "guest");

      queueSession = queueConnection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);


      queue = new HornetQQueue(qname);

      queueSender = queueSession.createSender(queue);

      queueReceiver = queueSession.createReceiver(queue);


      2) I'm running two HornetQ servers behind a loadbalancer (netscalar), it is configured correctly to forward the requests to 5455 ports of the HornetQ Servers. We are using "Roundrobin" policy in the load balancer.

      3) When i'm running the above program it connects to only one Queue properly running behind the load balancer. I see only the


      The problem is my program is always sending messages to only one server through my load balancer and i'm just worried why my Round Robin policy is not defined in netscalar is not working. I was expecting my client program to connect to the server through my load balancer and sends messages to netscalar which in turn forward the messages to either one of the hornetq server.


      Does this configuration and above code will work for me? Do you want to see some configuration details, let me know i will provide details.


      -- Muthu

        • 1. Re: HornetQ load balancing issue
          Justin Bertram Master

          Typically it's not possibly to load-balance JMS connection with a hardware load-balancer like is often done with e.g. HTTP.  This is because JMS connections are stateful (and HTTP connections are not).  When the client creates a connection there is an actual resource created on the server (i.e. the session) that is used by the client until the client closes the connection. 


          If your client is connecting through the load-balancer and the messages it send with this connection are only going to one of the servers, then that is likely the correct behavior.  If the load-balancer tried to send messages to the other node it would get an exception because there would be no session on the server to accept the messages.

          • 2. Re: HornetQ load balancing issue
            Muthukumaran Manickavasagam Newbie

            You may be right. But what makes me to worry is that WMQ receives messages in round robin fashion from the same load balancer. I wish to see fully functional fail over support with clusterning in HornetQ,


            -- Muthu