37.2.3. Application-Level fail-over

In some cases automatic client fail-over may not be desirable, and you may prefer to handle any connection failure yourself, and code your own manual reconnection logic in your own failure handler. This defined as application-level fail-over, since the fail-over is handled at the user application level.
To implement application-level fail-over, if using JMS, set an ExceptionListener class on the JMS connection. The ExceptionListener will be called by HornetQ in the event that connection failure is detected. In ExceptionListener, close the old JMS connections, potentially look up new connection factory instances from JNDI and creating new connections. In this case you may well be using HA-JNDI to ensure that the new connection factory is looked up from a different server.
If using the core API, the procedure is very similar: set a SessionFailureListener on the core ClientSession instances.