Syntax
- Shared filter form:
$share/{ShareName}/{TopicFilter}. - ShareName must not contain
/,+, or#. - The topic filter part can use normal MQTT wildcards.
Route MQTT publications through regular subscribers, shared groups, and broker-specific worker selection policies.
Compare regular fan-out with MQTT shared subscriptions. A matching publication is delivered to every matching non-shared subscription, but to only one session inside each matching shared subscription group. The broker chooses the session; round-robin is a common policy, not a protocol guarantee.
Marks this subscription as shared instead of regular fan-out.
Sessions with the same share name and topic filter form one group.
Standard MQTT filter syntax; wildcards still match topic levels.
The published topic matches the group filter.
Publishes message 1 to sensors/temperature.
Finds one shared group with a matching filter.
Only one session in the group receives this publication.
Each worker has the same shared subscription filter. The highlighted worker receives the current message.
The broker first checks filter syntax, then topic matching, then chooses a session for each matching shared group.
The publication matches $share/processors/sensors/temperature, so the broker sends one copy to one active session in the processors group.
$share/{ShareName}/{TopicFilter}./, +, or #.The broker selects among subscribing sessions. In practice those sessions often map to worker processes or service instances, but MQTT specifies session behavior.
The publication topic still has to match the topic filter after the share prefix and share name are removed. Shared subscriptions do not change MQTT topic matching rules.
Shared subscriptions load-balance delivery. They do not replace QoS handshakes, retained-message semantics, or application-level idempotency.