OnixS C++ B3 BOE Binary Order Entry  1.2.0
API Documentation
Schema Versioning
Note
B3 describes the SBE Schema Versioning in the "Messaging Guidelines" documentation.
The OnixS::B3::BOE::Messaging::SchemaTraits structure contains information about the highest SBE Schema Version that is supported by the SDK.

Schema Compatibility

OnixS::B3::BOE::Messaging::SchemaTraits::Id: if this attribute is different from the ID of the SBE Schema that is used by B3, the Handler is incompatible with the particular B3 environment. If an attempt to decode a message with a different schema id is made, an error will be reported and the connection will be terminated. In this case, please contact OnixS Support to obtain a newer version of the Handler.

OnixS::B3::BOE::Messaging::SchemaTraits::MinimalVersion defines the minimal version supported. If an attempt to decode a message with a lower version is made, an error will be reported, and the connection will be terminated. If an attempt to create a message with a lower version is made, the exception is thrown.

OnixS::B3::BOE::Messaging::SchemaTraits::Version: the latest supported version. It is the default version for creating outgoing messages.

Using Specific SBE Version

OnixS::B3::BOE::SessionSettings::messagingSchemaVersion specifies the SBE messaging version to be used session-wide. The default value is OnixS::B3::BOE::Messaging::SchemaTraits::Version. The session uses this version for session-level messages.

The Handler checks all the messages a user sends to comply with this attribute (this is done in debug mode only); otherwise, it throws an exception.

To create an application-level message of the lower version (but it is still should be higher than OnixS::B3::BOE::Messaging::SchemaTraits::MinimalVersion), pass the required version to its constructor. For example:

using namespace OnixS::B3::BOE::Messaging;
typedef MessageHolder<NewOrderSingle102> NewOrderSingle;
NewOrderSingle order(SchemaTraits::MinimalVersion);

The Message can take the version from the Session's instance:

void onExecutionReportNew(const Messaging::ExecutionReportNew200&, Session* sn) override
{
typedef MessageHolder <NewOrderSingle102> NewOrderSingle;
NewOrderSingle order(*sn);
sn->send(order);
}

To obtain the SBE Schema version of the message, use the following member function:

void onExecutionReportNew(const Messaging::ExecutionReportNew200& msg, Session*) override
{
std::cout << "Message version: " << msg.version() << std::endl;
}

Using several SBE Schema versions simultaneously

It is possible to use several Sessions with different SBE Schema versions simultaneously. The desired SBE Schema version should be specified per session. In the following snippet, modernSession is configured to use the most recent schema version supported, i.e.: to use OnixS::B3::BOE::Messaging::SchemaTraits::Version - the default value for OnixS::B3::BOE::SessionSettings::messagingSchemaVersion and legacySession is configured to use the previous schema version:

class Listener : public SessionListener
{
void onSessionEstablished(Session* sn)
{
typedef MessageHolder<NewOrderSingle102> NewOrderSingle;
// Create an order with version specified for the passed session instance
NewOrderSingle order(*sn);
fillOrder(order);
sn->send(order);
}
};
Listener listener;
// This instance uses the most resent schema version (i.e. `SchemaTraits::Version` - default value)
Session modernSession(getSettings(), &listener);
// This instance uses the previous schema version
Session legacySession(getSettings().messagingSchemaVersion(SchemaTraits::Version - 1), &listener);