Message Structure
All messages have a consistent structure defined as follows:
This structure applies whether SBE is being used as the serialization mechanism or whether an alternative serialization is being used, in which case alternative payloads will be automatically wrapped within an envelope which provides these header fields.
SBE Header
Contains the following standard SBE header fields. More details of these can be found in the Simple Binary Encoding documentation. These fields are automatically applied when using the API and therefore should not need to be set manually.
| Field | Description |
|---|---|
| blockLength | The block length of the SBE message |
| templateId | The type of the message |
| schemaId | The schema of the message |
| schemaVersion | The schema version of the message |
KeyHeader
The SBE Header is the standard SBE header. KeySquare conscientiously decided not disrupt the standard SBE structure. Instead, the KeyHeader contains various metadata required for our applications. These fields are fixed offsets within the SBE byte buffers ensuring performance.
Contains the following fields:
| Field | Responsibility | Description |
|---|---|---|
| sequencerId | Platform | A unique identifier applied by the Sequencer. |
| sequencerNanoTime | Platform | The timestamp that this message was received by the Sequencer. |
| relayNanoTime | Platform | The timestamp that this message was received by the Relay supplying the message to the application. |
| messageType | Platform | An indicator that provides information about the type of relay that provided the message, e.g. Cached, Live. |
| applicationId | Application | The unique identifier of the application that published the message. |
| flags | Application | See below for more details. |
| topicSource | Application | The Topic Source (see topic structure). |
| topicGroup | Application | The Topic Group (see topic structure). |
| topicId | Application | The Topic Id (see topic structure). |
| inceptionNanoTime | Application | Application provided timestamp which indicates when an item of data was created. |
| sourceSequencerId | Application | Optional field that can be used to store the sequencer number of an incoming message that has triggered a message to be published - this can be useful in cause-and-effect tracking. |
Message Flags
The following boolean flags can be set to control various messaging behaviours. When creating new messages, the default value for all of these flags will be false. These flags only need to be set when a non-default behaviour is needed.
| Flag | Description |
|---|---|
| editable | Indicates whether edit requests can be made for this data. Messages are not editable by default |
| ephemeral | Indicates whether the message should be cached. Messages are cached by default |
| eternal | Indicates whether the message should remain in the cache and not be auto-evicted when an application that published the data goes offline. Messages are not eternal by default and will therefore participate in auto-eviction. Messages cannot be both ephemeral and eternal. |
| voided | Indicates whether the message is valid for use. Voided messages are evicted from the cache. Messages are "valid" by default, i.e. not "voided" |