OnixS C++ FIX Engine  4.10.1
API Documentation
Controlling Outgoing Message Flow

When an application sends FIX messages at a high rate, there can be overflow issues. This can happen for different reasons, e.g., the outgoing TCP buffer size is not enough, slow network, the counterparty cannot process received messages in time, etc. Such issues can have a negative impact on the application and lead to disconnections of FIX connections.

Therefore, it makes sense to detect such issues on the application level and try to prevent them. When a session sends a FIX message and the send socket function fails, the serialized FIX message is stored in the sending queue for the subsequent sending by the sending thread. To control that there are no pending messages in this sending queue, one can use the OnixS::FIX::Session::outboundQueueBytes method. If this method returns a large value, which increases in time, then there is an overflow issue, so it makes sense to wait to send messages until this value is decreasing, for example:

// Set some pending bytes threshold.
// This value depends on the message's rate, size, network speed, etc.
const size_t PendingBytesThreshold = 1024 * 1024 * 10;
while(sendMessages)
{
// Application's message sending flow.
if(session.outboundQueueBytes() < PendingBytesThreshold)
session.send(&order);
else
{
// Wait until the number of pending bytes is decreasing.
// Perform some other useful work.
}
}

Additionally, one can set a limit of the sending queue size in bytes via the OnixS::FIX::Session::sendQueueMaxSize method or the corresponding Engine's setting. The TCP connection will be disconnected when an overflow issue happens and the sending queue size exceeds this limit.