A single FIX session can exist across multiple sequential (not concurrent) physical connections. Parties can connect and disconnect multiple times while maintaining a single FIX session. That is, once the OnixS::FIX::Session::logout method is called, FIX Connection is terminated. However, when FIX Connection is terminated, the FIX session doesn't end its lifetime. It is possible to continue the session later, using either OnixS::FIX::Session::logonAsAcceptor or OnixS::FIX::Session::logonAsInitiator methods again. In other words, FIX Session is comprised of one or more FIX connections.
All FIX messages are identified by a unique sequence number (the MsgSeqNum field) within the bounds of a single FIX session. Sequence numbers are initialized at the start of each FIX session, starting at 1 (one), and increment throughout the session. Each session establishes an independent incoming and outgoing sequence series.
OnixS C++ FIX Engine automatically synchronizes sequence numbers, while reconnecting during a FIX session, on the basis of the information previously stored in the Engine log files.
Monitoring of the sequence numbers enables parties to synchronize applications gracefully, while reconnecting during a FIX session. To get the expected sequence number of the next incoming message, the OnixS::FIX::Session::inSeqNum member is exposed, as well as the OnixS::FIX::Session::outSeqNum member, to get sequence number of the next outgoing message.
Resetting inbound and outbound message sequence numbers back to 1, for whatever reason, constitutes the beginning of a new FIX session. The OnixS::FIX::Session::resetLocalSequenceNumbers method must be used to backup the previous log files and reset the sequence numbers to 1.
Some implementations of the FIX protocol (FIX Dictionaries) expect that FIX Session coincides with FIX Connection. In other words, message sequence numbers must be reset back to 1 after OnixS::FIX::Session::logout messages are exchanged, and the FIX connection is terminated.
To interact with such FIX dictionaries, keepSequenceNumbersAfterLogout parameter of the OnixS::FIX::Session::Session constructor should be set to
false. In this case, the OnixS::FIX::Session::shutdown() method sequence numbers are set back to 1. Next time, when the OnixS::FIX::Session object is created incoming and outgoing, sequence numbers will start from 1 (in other words, new FIX Session will be created).