Global-shared subscriptions in MQTT

You can configure global-shared durable and global-shared non-durable topic subscriptions to be shared by Eclipse Amlen MQTT client applications. Shared subscriptions are an Eclipse Amlen extension of MQTT and, as such, are not part of the MQTT specification. Applications that depend on Eclipse Amlen global-shared subscriptions are not portable to other MQTT servers.

Factors to consider before you start to develop MQTT applications to use global-shared subscriptions:
  • Your application might need to block access to global-shared subscriptions if they are not to be used.
  • If you intend your application to use only global-shared subscriptions, you might consider designing your application to check input topic strings to ensure that they are correctly configured to create, or join, global-shared subscriptions in the Eclipse Amlen server.
  • When an application uses a global-shared subscription, it does not receive all of the published messages; it receives a subset of messages from the topic being subscribed to and shares the load of processing all of the published messages.
  • Applications that depend on Eclipse Amlen global-shared subscriptions are not portable to other MQTT servers.
  • The order of delivery of messages on shared subscriptions cannot be guaranteed. If you need to preserve message order, either include message order information for use by the client in the content of the message or do not use shared subscriptions.

To subscribe to topics on global-shared durable subscriptions, the MQTT SUBSCRIBE request must specify:

$SharedSubscription/SubName/topicFilter

where:

$SharedSubscription
Indicates that the target of the SUBSCRIBE request is a global-shared subscription. This literal string is case sensitive.
SubName
Is the name of the shared subscription.
This value must not include any forward slashes ( / ).
topicFilter
Is a standard MQTT topic filter for any type of topic subscription. It can contain a single topic name, or it can contain a topic filter that includes wildcards. For information about wildcards in subscriptions, see Wildcards.

As for any MQTT topic subscription, you must ensure that there is a topic policy with Subscribe authority for the topic or topics associated with your shared subscriptions. See Topic filters for MQTT global-shared subscriptions for further information about configuring topic policies for your shared subscriptions.

If you are using a global-shared durable subscription then you must ensure that there is also a subscription policy to authorize clients to use the global-shared durable subscription. The Subscription field of the subscription policy must have the same value as the SubName in the MQTT SUBSCRIBE request. Receive authority must be granted for all subscribers. Control authority must be granted for the subscriber that initially creates the global-shared durable subscription.

See Subscription policy for further information about configuring subscription policies for your global-shared durable subscriptions

MQTT applications end their use of a global-shared subscription by issuing an MQTT UNSUBSCRIBE request or by disconnecting. If the client being removed from the subscription is the last user of the subscription, the subscription is deleted. You should not share subscriptions between protocols, but if the global-shared subscription is also being shared by one or more JMS applications, the subscription is not deleted until the final JMS application has explicitly unsubscribed from it.