In the above picture, three subscribers subscribe to the same topic using a shared subscription method, where topic is the real topic name they subscribed to, and is a shared subscription Prefix. EMQX Broker supports shared subscription prefixes in two formats:

    Shared subscriptions prefixed with $ share/<group-name> are shared subscriptions with groups:

    For example, suppose that subscribers s1, s2, and s3 belong to group g1, and subscribers s4 and s5 belong to group g2. Then when EMQX Broker publishes a message msg1 to this topic:

    • Only one of s1, s2, s3 will receive msg1

    Shared subscriptions prefixed with are shared subscriptions without groups. It is a special case of $share subscription, which is quite similar to all subscribers in a subscription group:

    Balancing strategyDescription
    hash_clientidAccording to the hash value of the publisher ClientID
    hash_topicAccording to the hash value of the message’s topic name
    localSelects random subscriber connected to the node which received the message. If no such subscribers present, selects a random cluster-wise
    randomSelect randomly among all subscribers
    round_robinAccording to the order of subscription
    stickyFirst dispatch is random, then stick to it for all subsequent messages until that subscriber goes disconnected or that publisher reconnects

    TIP

    Whether it is a single client subscription or a shared subscription, pay attention to the client performance and message reception rate, otherwise it will cause errors such as message accumulation and client crash.