This page applies to Java Broker versions before 0.22. For up to date details of how to enable heartbeating from the Qpid JMS clients, refer to the JMS client documentation

AMQP Heartbeating

Heartbeating at the AMQP protocol level works by sending a small "heartbeat" frame whenever the (half-)connection is idle... That it each peer is responsible for sending a heartbeat frame if it has not sent other data for a given period of time.

Qpid allows for the heartbeat interval to be set on a per client basis, and set to broker configured default if a client does not explicitly set the heartbeat interval.

The successful receipt of a heartbeat message from a broker/client does not imply that it is able to send or receive messages - it is merely indicative that the TCP connection is alive and the broker/client is minimally operational. Higher level application heartbeats are required to test the full functional operability of the client/broker.

To set the heartbeat interval on the client, the system property "amqj.heartbeat.delay" needs to be set to an integer number representing the desired interval in seconds (for example by passing -Damqj.heartbeat.delay=30 on the JVM command-line to get a 30 second interval).

If the heartbeat interval is not explicitly set on the client then the default interval from the broker is taken, this is set in the config.xml file, e.g. in the default config:

<heartbeat>
<delay>0</delay>
...
</heartbeat>

A <delay> of zero means "no heartbeating".

The client or broker will detect a connectivity problem when it has received no heartbeat, or other data, from its peer for delay * timeoutFactor seconds. The timeoutFactor is set separately for client and broker - the client does not default to using the broker value if it is not set. The timeoutFactor is set on the client by setting the system property "amqj.heartbeat.timeoutFactor" to a valid floating point number. The client and broker default timeoutFactors are (independently) set at 2.0.

If heartbeating is activated, and a client does not receive a heartbeat from the server for delay * (client)timeoutFactor seconds then it closes the TCP connection and activates the failover logic.

If heartbeating is activated, and a broker does not receive a heartbeat from the server for delay * (server)timeoutFactor seconds then it logs this event but does not take any further action (i.e. the connection is not closed, and processing of incoming data/sending outgoing data still occurs.

TCP SO_KEEPALIVE

Neither the client nor the broker (to version 0.5) set SO_KEEPALIVE on the TCP connection, nor is there are way to request them to do so using configuration.

  • No labels