• dev
  • MQTT Shared Subscription - Duplicate messages

Hello,

We decided to try out MQTT shared subscription to achieve load-balancing at the broker's level.

We had set up (say 2) multiple consumers subscribed to different channel; however, we ran into issues whereby same (& duplicate) message was delivered to each consumer. Our mqtt client qos is configured for level 1.
Our expectation was for one message to be delivered to one of consumers in the shared group.

$share/group_name/flespi/message/gw/channels/<channel_id_1>/+
$share/group_name/flespi/message/gw/channels/<channel_id_2>/+

Did we miss something on our setup? Any guidance will be greatly appreciated.

Thanks.

    VcmBcnInteg21 Hello,

    A shared subscription group must have the same topic filter for all clients. Each shared subscription group receives its own message despite different subscriptions.
    You can read the official documentation:
    https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901250
    Also we have a little explanation in our blog:
    https://flespi.com/blog/shared-subscriptions-yet-another-flespi-mqtt-broker-feature

    If you want to share topics between MQTT sessions, subscribe them all to the same filter $share/group_name/flespi/message/gw/channels/+/+ to share all messages from all channels.
    Or $share/group_name/flespi/message/gw/channels/<channel_id_1>,<channel_id_2>/+ if you want to share messages from <channel_id_1> and <channel_id_2>. CSV in the subscription filter is a unique feature of the flespi broker. Other features are described here:
    https://flespi.com/mqtt-broker

    6 days later

    Hello,

    Thanks for your response. While after making the change, we still encounter same message being sent to multiple consumers on our end. We then tried using setting QoS from 1 to 2 and that seemed to have done the trick. Our understanding was that QoS = 1 should've worked.

      VcmBcnInteg21 QoS does not have meaning here. The only meaning is the group name and subscription topic - they should be the same on all clients. If you have two subscriptions for the same group - they will be processed separately.

      QoS=1 should be sufficient for all cases.

        Write a Reply...