Show Table of Contents
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.FailoverMethodinterface.
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

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.