To provide a uniform technique to deal with SBE messages, the SDK exposes the Tag-based Messaging subsystem. This subsystem represents an additional "stabilization" layer between the SBE messages and user code. It allows users to achieve tolerance to changes in the SBE Schema by proving the tag-based access to message fields.
- Warning
- The Tag-based Messaging subsystem should not be used on the time-critical path because it does not provide the fastest way to access the data.
The subsystem classes are located in the OnixS::CME::iLink3::Messaging::TagBased
namespace.
Constructing Tag-based Messages
Every Tag-based message contains a constructor that accepts an SBE message:
struct MessageListener
{
{
std::cout << fixMessage.
type();
}
};
A Tag-based message can be created using OnixS::CME::iLink3::Messaging::MessageHolder and used just like a standard SBE message:
Tag-based messages can also be used with the OnixS::CME::iLink3::Testing::Gateway facilities:
std::unique_ptr<Testing::Gateway> gateway(createGateway());
const auto order =
report->
set(
;
gateway->send(report);
Listening to Tag-based Messages
The OnixS::CME::iLink3::TagBasedSessionListener class allows to subscribe to message related notifications and obtain incoming messages wrapped into Tag-based containers:
struct MyTagBasedSessionListener
{
void onMessage(
override
{
std::clog << "\nReceived:\n" << msg << std::endl;
}
};
MyTagBasedSessionListener listener;
Session session(settings, marketSegmentId, &listener);
Using Tag-based Messages
The following example shows how to access message fields and groups using the Tag-based Messaging subsystem:
{
{
std::cout
<< ", ManualOrderIndicator: "
std::cout
<< ", QuoteReqId: ";
std::cout << quoteReqIdValue;
else
std::cout << "Not presented";
std::cout
<< ", LiquidityFlag: ";
if(liquidityFlagField)
std::cout
else
std::cout << "Not presented";
std::cout
<< ", ShortSaleType: ";
try
{
std::cout
}
catch(std::runtime_error&)
{
std::cout << "Not presented";
}
if(entries)
{
for(
++index)
{
entries[index];
std::cout
<< ", BidPx[" << index << "]: "
}
}
}
}
- See also
- Tag Based Messaging Sample.