thingsboard / thingsboard-gateway

Open-source IoT Gateway - integrates devices connected to legacy and third-party systems with ThingsBoard IoT Platform using Modbus, CAN bus, BACnet, BLE, OPC-UA, MQTT, ODBC and REST protocols
https://thingsboard.io/docs/iot-gateway/what-is-iot-gateway/
Apache License 2.0
1.76k stars 845 forks source link

MQTT connector buffering #1465

Closed palexandridis closed 4 months ago

palexandridis commented 4 months ago

When subscribing to topics with retain flag set, the mqtt connector can receive all retained messaged since last connection. Under the broker section in the mqtt json configuration file, two keys have been introduced for MQTT v5.

Example configuration for MQTT v5:

"broker": {
    "name": "Default Local Broker",
    "host": "127.0.0.1",
    "port": 1883,
    "clientId": "ThingsBoard_gateway",
    "version": 5,
    "cleanStart": false,
    "sessionExpiryInterval": 604800,
    "maxMessageNumberPerWorker": 10,
    "maxNumberOfWorkers": 100,
    "sendDataOnlyOnChange": false,
    "security": {
      "type": "basic",
      "username": "user",
      "password": "password"
    }

When using MQTT v3, similar behavior can be achieved with:

The above functionality is relevant for retained mqtt topics that include a timestamp such as:

{"temperature" : 23, "timestamp": 1721233307943}

Please note: Although the above changes work when executing the gateway locally from source, they do not work when executing the gateway using docker. To my understanding, the issue is related to the mqtt connection of the gateway to thingsboard when publishing received messages.

CLAassistant commented 4 months ago

CLA assistant check
All committers have signed the CLA.