Configuring heartbeats between DataSource applications

Here we explain what heartbeats are and how to configure DataSource applications to exchange heartbeat messages.

Overview

Two DataSource applications can exchange heartbeat messages, which enables them to detect the loss of the connection between them, even in situations where the operating system can’t or doesn’t inform the application that the connection is lost.

A DataSource application won’t send heartbeats if it’s already sending data, with the exception of Java-based applications (implemented using the Caplin Integration Suite), which always send heartbeats if they’re enabled.

When heartbeats are enabled, the receiving DataSource application applies the heartbeat-time and heartbeat-slack-time configuration settings to the receipt of all data. So if the application doesn’t receive either some data or a heartbeat within the time heartbeat-time + heartbeat-slack-time, it assumes the connection to the sending peer is down.

Configuring heartbeats

Heartbeats are enabled by default from DSDK 7.1.16 (Liberator 7.1.15, Transformer 7.1.10), DS.NET 7.1.16, and DataSource for Java 7.1.13. For the default values, see configuration items datasrc-heartbeat-time and datasrc-heartbeat-slack-time.

To enable heartbeats in older versions, in the configuration for at least one of the DataSource applications, define the heartbeat-time option in the add-peer item that refers to the other application:

add-peer
  remote-name fxpriceadapter1
  heartbeat-time 5 (1)
  ...
end-peer
1 Enable heartbeat messages every 5 seconds between this DataSource application and the fxpriceadapter1 peer.

In the example above, the DataSource application will send heartbeats to the peer fxpriceadapter1 every 5 seconds.

Heartbeat packets include the sending application’s value for heartbeat-time. When a DataSource receives a heartbeat from a peer, it compares the value of heartbeat-time in the heartbeat with its own value for heartbeat-time. If the DataSource’s value for heartbeat-time is undefined or greater than the value of heartbeat-time in the received heartbeat, then the DataSource resets its own heartbeat-time to the value in the heartbeat.

In a connection between two DataSource applications, only one of the applications needs to be configured to send heartbeats. Sending a heartbeat to a DataSource application that is not configured to send heartbeats will cause that application to begin sending heartbeats.

Additionally, you may want to configure the related add-peer::heartbeat-slack-time option, though it does have a default setting of 2.0 seconds which should be adequate for most purposes.


See also: