1 2 Previous Next 26 Replies Latest reply on May 29, 2014 1:51 AM by Yair Ogen

    Core API Client load balancing

    Yair Ogen Expert

      I've found this section in the manual but I am experiencing some strange behavior:


      HashMap<String, Object> map = new HashMap<String, Object>();
      map.put("host", "myhost");
      map.put("port", "5445");
      TransportConfiguration server1 = new TransportConfiguration(NettyConnectorFactory.class.getName(), map);
      HashMap<String, Object> map2 = new HashMap<String, Object>();
      map2.put("host", "myhost2");
      map2.put("port", "5446");
      TransportConfiguration server2 = new TransportConfiguration(NettyConnectorFactory.class.getName(), map2);
      ServerLocator locator = HornetQClient.createServerLocatorWithHA(server1, server2);
      ClientSessionFactory factory = locator.createSessionFactory();
      ClientSession session = factory.createSession();


      Assuming I have a 4 node cluster. 2 live servers and 2 backups. All are in the same group.


      What I though I need to do is like above, create 4 transports. One for each node.


      I then create multiple producers sending messages concurrently, but instead of seeing a round robin behavior, I see the producer sends twice the messages. I think it is once for each live server. So, if I start 2 consumers and I expected each to handle half of the messages, they both get the same messages.


      What am I missing here?

        1 2 Previous Next