16.5. Failover Behavior in Java JMS Clients

In Java JMS clients, with a cluster that uses a Virtual IP, simply specify the Virtual IP address as the broker address. Fail-over is handled transparently by the cluster manager.
In a case where you have a cluster that does not use a Virtual IP address, client fail-over is handled automatically if it is enabled in the connection. You can configure a connection to use fail-over using the failover property:
connectionfactory.qpidConnectionfactory = amqp://guest:guest@clientid/test?brokerlist='tcp://localhost:5672'&failover='failover_exchange'
This property can take five values:

Fail-over Modes

failover_exchange
If the connection fails, fail over to any other broker in the cluster. This is provided for backward compatibility. Use of a Virtual IP (and transparent server-side failover) is recommended.
roundrobin
If the connection fails, fail over to one of the brokers specified in the brokerlist.
singlebroker
Fail-over is not supported; the connection is to a single broker only.
nofailover
Disables all retry and failover logic.
<class>
Any other value is interpreted as a classname which must implement the org.apache.qpid.jms.failover.FailoverMethod interface.
In a Connection URL, heartbeat is set using the idle_timeout property, which is an integer corresponding to the heartbeat period in seconds. For instance, the following line from a JNDI properties file sets the heartbeat time out to 3 seconds:
connectionfactory.qpidConnectionfactory = amqp://guest:guest@clientid/test?brokerlist='tcp://localhost:5672'&idle_timeout=3