Shared Subscription Syntax for MQTT

jfg1306 Member Posts: 14 ✭✭

Hello Solace Community,

I have a question regarding the usage of shared subscriptions with an MQTT client.
I found two different prefixes in the documentation and am curious to learn which is used in which case.

I found in the documentation the following hint (see: ) :

Syntax of Shared Subscriptions

A shared subscription has the form:



ShareName is the identifier associated with the shared subscription. It may not contain * or >.

topicFilter is the topic filter.

But inside the MQTT operational behaviour I find this (see on 4.8.2 ):

A Shared Subscription's Topic Filter MUST start with $share/ and MUST contain a ShareName that is at least one character long[MQTT-4.8.2-1]. The ShareName MUST NOT contain the characters "/", "+" or "#", but MUST be followed by a "/" character. This "/" character MUST be followed by a Topic Filter[MQTT-4.8.2-2] as described in section 4.7.

For me it only worked with $share in the beginning. But I am now unsure if I missunderstood something. Is the first documentation I quoted and linked not relevant for me ? I was under the assumption that I am using Direct Messaging with QoS 0 and MQTT. So the documentation above should also have worked in my opinion.

So is $share or #share correct ? Or maybe both ? :-)





  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 499 admin

    Hey @jfg1306 - so #share/<ShareName>/<topicFilter> notation is when you are using solace SMF. However when you use MQTT protocol and want to take advantage of the shared subscriptions then you will use the $share/<ShareName>/<topicFilter>

    So technically, both are correct but depending on which protocol you are using :) Hopefully this helps!

  • mpatel
    mpatel Member, Employee Posts: 3 Solace Employee

    Hi Jan-Filip

    If you are working with the Solace SMF based APIs like JCSMP, Java, Python etc. shared subscription has the form: #share/<ShareName>/<topicFilter>

    For MQTT client, $share/{ShareName}/{filter} is the correct form as mentioned in section 4.8.2 and it is as per the MQTT v5 specs.

  • jfg1306
    jfg1306 Member Posts: 14 ✭✭

    Hi @Tamimi and @mpatel ,

    thank you both the answer. Now I got it, so both are valid but are used based on the used messaging API.