Client load balancing

Solution Verified - Updated -

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 6.2.x

Issue

  • I have code working well with client side load balancing using HornetQ's core API. I provide two TransportConfigurations with live and backup credentials accordingly.

  • RoundRobin load balancing policy being used by default. Although this worked for a long time, with no code changes started to fail as load balancing strategy chooses always the second (backup) instance and since I have infinite retries it never checks the other (master) server.

Resolution

Please make sure to set setInitialConnectAttempts attribute to an appropriate value, 1 or 2 would suffice. Never specify -1 as this forces the broker to indefinitely retry to connect to the first transport configuration in the list and would not iterate on the list of given transport configurations.

serverLocator.setInitialConnectAttempts(2);

This configuration would make the broker to iterate the list of configuration after attempting twice on the first transport configuration.

Root Cause

  • The corresponding client code sets setInitialConnectAttempts at -1. This makes the broker to continually attempt to retry and reconnect to the first server configuration in the list of transport configurations and would not attempt to iterate through the given list of transport configurations.

Diagnostic Steps

  • Please make inspect the value specified for setInitialConnectAttempts attribute in the client code.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.