-
Notifications
You must be signed in to change notification settings - Fork 121
Session MetaData
Session metadata is an easy way to associate information about your internal system with FIX messages. Conceptually each Session has metadata that is associated with it. The metadata shares its life-cycle with the sequence of the FIX session - so when a sequence number reset happens the meta data gets reset as well. Here are some example uses for metadata:
- Storing internal transaction ids or sequence numbers that correlate to the last processed FIX message.
- As an acceptor you might store an internal company identifier that corresponds to a FIX session.
- Store topic identifiers that a Session's messages may come from.
Metadata is just a series of bytes and any encoding format can be used though binary formats, such as SBE, are strongly encouraged for performance reasons. Note: metadata can be read when sessions are connected or disconnected and it persists over engine restarts if the sequence numbers are persistent.
You can write metadata using either the FixLibrary.writeMetaData()
or the overloads of Session.send()
that take a metadata buffer. The return Reply
object of FixLibrary.writeMetaData()
can be used to know when the write has completed.
When you receive a SessionAcquiredHandler
callback the session metadata can be read out of it's SessionAcquiredInfo
parameter. The SessionAcquiredInfo.metaDataStatus()
should be checked before reading the metadata buffer to ensure that there is metadata to be read.
If you want to read the session metadata for a Session at other times then FixLibrary.readMetaData()
can be used.
With the current metadata file design if you update the metadata slot growing it in size then fragmentation in the file can occur using unnecessary space inefficiently. It is not required, but recommended, to use a small and fixed size metadata buffer.