Here we explain what heartbeats are and how to configure DataSource applications to exchange heartbeat messages.
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.
Heartbeats aren’t enabled by default. To enable them, 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:
# # Peers configuration # # add-peer remote-name fxpriceadapter1 # # Enable heartbeat messages every 5 seconds # between this DataSource application # and the fxpriceadapter1 peer. # heartbeat-time 5 ... end-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 heartbeat-slack-time option, though it does have a default setting of 2.0 seconds which should be adequate for most purposes.
How can I… Use timers in DataSource applications