# Exclusive subscription

The exclusive subscription allows mutually exclusive subscriptions to topics. Only one subscriber is allowed to subscribe to a topic at a time. Other subscribers will not be able to subscribe to the corresponding topic until the current subscriber unsubscribe the subscription.

The prefix and example of exclusive subscriptions:

ExamplePrefixReal Topic Name

When a client A subscribes to $exclusive/t/1, other clients will fail to subscribe to $exclusive/t/1 until A cancels the subscription to $exclusive/t/1 .

Note: Exclusive subscriptions must be prefixed with $exclusive/, in the above example, other clients can still successfully subscribe via t/1.

# Subscription error code

0x8Fuse $exclusive/ without exclusive subscription enable
0x97A client has already subscribed to this topic

# Configuration settings

Exclusive subscription is disabled by default and can be configured in etc/emqx.conf:

mqtt.exclusive_subscriptionbooleanfalsedefault switch for exclusive subscription
zone.external.exclusive_subscriptionbooleannot setswitch for exclusive subscription on external zone
zone.internal.exclusive_subscriptionbooleannot setswitch for exclusive subscription on internal zone

If the value of exclusive_subscription is not set on the zone, EMQX will use mqtt.exclusive_subscription to determine whether the function is enable.