FIX Antenna ANSI C  2.18.0
 All Data Structures Variables Pages
FIX Session

Persistent session

Persistent session is a session with persistent storage.

B2BITS_Session B2BITS_FixEngine_CreateSession(B2BITS_Application* apApp, const char* aSenderCompID, const char* aTargetCompID,
B2BITS_FIXVersion aVer, B2BITS_SessionExtraParameters* pParam, const B2BITS_MessageStorageType storageType /*B2BITS_persistentStorageType*/)

Session state is stored on a disk and can be restored after failure. The following information is stored for a session:

Transient session

Transient session is a session with transient storage.

B2BITS_Session B2BITS_FixEngine_CreateSession(B2BITS_Application* apApp, const char* aSenderCompID, const char* aTargetCompID,
B2BITS_FIXVersion aVer, B2BITS_SessionExtraParameters* pParam, const B2BITS_MessageStorageType storageType/*B2BITS_transientStorageType*/)

Session state is stored in memory, which increases performance highly. This is the recommended way in case when the session is not required to provide a fail-over by itself.

Session state

From the moment of creation till till the moment of destruction the session uses the state that dictates its reaction to events. The session state can be obtained using the Engine::Session::getState() method, which returns Session::State.

dot_inline_dotgraph_2.png

Sequence number handling

The session is always assigned with two sequence numbers:

Both sides must maintain the two values and ensure that they are in sync. There are two types of sequence numbers desync:

Both sequence numbers start from 1 when the session is created from scratch. After the correct session termination sequence numbers are reset to 1. If connection is terminated non-gracefully sequence numbers will continue after it is restored. In fact a lot of service providers never reset sequence numbers during the day. There are also some, who reset sequence numbers once per week. There are several cases to handle such deviation from standard in FIX Antenna

Resetting sequence number

It is recommended that a new FIX session is established once within each 24 hour period. The new set of sequence numbers can be set by sending a Logon message with the ResetSeqNumFlag set. FIX Antenna supports this feature via ResetSeqNumAfter24hours configuration option.

Late delivery vs rejecting

When session connection is lost, the initiator tries to reconnect, which may take some time (or even infinity), and the acceptor waits for reconnect. For both sides message delivery is impossible. FIX Antenna provides two different approaches to message handling in this case:

The B2BITS_SessionExtraParameters::enableMessageRejecting_ parameter controls if Message rejecting is enabled or not (by default it is disabled). The MessageTimeToLive configuration file property specifies how long the session waits for connection restore (i.e. before rejecting the message). If the connection is not restored during the MessageTimeToLive interval - the session starts rejecting messages by calling B2BITS_Application::OnMsgRejectEvent() for each rejected message.