Flow control is typically employed in controlling fast producers from overloading slow consumers in producer-consumer scenarios. There may be several reasons for a fast producer-slow consumer scenario. For example, the consumer can be on a low resource footprint; or the message broker, which lies in the middle of the producer and the consumer, may get overloaded at a particular moment due to message accumulation within the broker itself. This can cause message broker instances to run out of resources, such as memory.
WSO2 Message Broker, primarily supports memory-based flow controlling. You can configure an MB server instance using two parameters; <globalMemoryTreshold>
(default value is 0.4) and <globalMemoryRecoveryThreshold>
(default value is 0.5). The global memory threshold is the memory threshold at which flow controlling is enabled, whereas the global memory recovery threshold is the memory threshold at which flow controlling is disabled and message publishing is resumed. The rate at which messages are transmitted is controlled by exerting back-pressure when the defined global memory threshold or message count threshold per connection exceeds. At this point, message acceptance is blocked temporarily until the producer is notified of memory recovery. In the meantime, a background process constantly checks whether the memory is recovered, and when the memory is available, the producer is notified and can resume sending messages to the server. Flow control configurations are defined in the <MB_HOME>/repository/conf/advanced/andes-config.xml
file.
In an event where a message is not published within a configurable amount of time (defined by the qpid.flow_control_wait_failure
system property with a default value of 120s) at the client-end, the client connection established with the server for the task of message publishing is terminated and an error is thrown. The qpid.flow_control_wait_notify_period
system property (default value is 5s) can effectively be used to print a log message periodically after the configured amount of time.