Message Sequence Numbers
Understanding Message Sequencing
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.
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.
The FIX Engine automatically synchronizes sequence numbers when reconnecting a FIX session from the information that was previously stored in the Session log files.
Changing Session Sequence Numbers
Monitoring sequence numbers enable parties to synchronize applications gracefully when reconnecting during a FIX session.
To get the expected sequence number of the next incoming message use the InSeqNum property.
To get the sequence number of the next outgoing message use the OutSeqNum property.
Resetting inbound and outbound message sequence numbers back to
1, for whatever reason, constitutes the beginning of a new FIX session.
Use the ResetLocalSequenceNumbers() method to back up the previous log files and reset the sequence numbers to
Both InSeqNum and OutSeqNum
properties can be used to set expected sequence numbers manually before a FIX connection is established.
However, it is NOT recommended to use these properties to reset the message sequence numbers to
Instead, use the ResetLocalSequenceNumbers() method.
To work with such FIX venues, the
keepSequenceNumbersBetweenFixConnections parameter of Session(String, String, Dictionary, Boolean, SessionStorageType, String)
constructor should be set to
false. In this case after the Logout(Boolean) method sequence numbers are set back to 1. Next time when the Session instance
is created incoming and outgoing message sequence numbers will start from
1 (in other words, a new FIX Session will be created).