Search code examples
queuemqttiot

Is there a way to control the message output speed of MQTT broker?


I am planning an MQTT project with multiple publishers. MQTT broker receives messages from different publishers. Is there a way to control the message output rate from the MQTT broker? For example, the broker queue forward messages to subscribers at 2 seconds interval. But the broker receives messages all the time. In such a way, can we control the exit rate from MQTT broker?


Solution

  • No, not really.

    It's important to understand that MQTT is pub/sub not really a message queue system.

    It is worth remembering that if the subscribing clients can not consume and process messages quicker than they are created then the system will eventually fail, they will have to back up somewhere (most likely in the broker) which will eventually fail due to either memory or storage exhaustion.

    Assuming the client is subscribed at QOS 1 or 2 and the broker is configured with only 1 inflight message at a time, then the client should be able to control the rate it handles messages by controlling how it handles the QOS handshake. But this tends to be a bad idea for the reasons already mentioned and not all clients give you any control over the handshake steps.