The B3 has limits on sending messages per time unit (throttling). If an application sends messages too often, they can be rejected, and finally, the session can be terminated. To not exceeds the limits, there is the OnixS::B3::BOE::Session::throttle method. This method performs the throttling of a session. It must be called before each send function call. If the count of messages per 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::B3::BOE::Session::throttlingLimit method is used to set throttling limit parameters:
Also, there is the OnixS::B3::BOE::Session::tryThrottle method. It checks the throttling of a session, but it does not block the execution. If the count of messages per time unit exceeds the throttling limit, the function returns the delay (in milliseconds) until the sending becomes possible. Otherwise, it returns 0
. This method can be helpful when one needs to detect that the message's rate exceeds the limit and react in some specific way: