OnixS C++ FIX Engine  4.10.1
API Documentation
Message Throttling

Many venues have limits of sending messages per time unit (throttling). If an application sends messages too often, then they can be rejected. To not exceeds the limits, there is the OnixS::FIX::Session::throttle method. This method performs the throttling of a session. It must be called before each a send function call. If the count of messages per a time unit exceeds a throttling limit, the function will be blocked until the given time interval is passed. The waiting is performed in the busy-wait (spin) mode to exclude the context switching overhead. The OnixS::FIX::Session::throttlingLimit method is used to set throttling limit parameters:

using namespace OnixS::FIX;
const int MessagesPerSecondLimit = 10;
const int ThrottlingIntervalMillisecond = 1000;
const std::string AcceptorHost = "localhost";
const int AcceptorPort = 5000;
Message order(FIX42::Values::MsgType::Order_Single, ProtocolVersion::FIX_42);
Session session("Sender", "Target", ProtocolVersion::FIX_42, &listener);
// Set throttling limit parameters.
session.throttlingLimit(MessagesPerSecondLimit, ThrottlingIntervalMillisecond);
session.logonAsInitiator(AcceptorHost, AcceptorPort);
// Emulate some sending flow of an application.
for (size_t counter = 0; counter < 100; ++counter)
{
// This method must be called before each of a send function call.
// If the count of messages (10 in our case) per a time unit (1 sec in our case) exceeds a throttling limit,
// this function will be blocked until the given time interval is passed.
session.throttle();
// A regular send call, which should be throttled.
session.send(&order);
}