From 746b996de40d4bdac1d29d87558b90ef860511fa Mon Sep 17 00:00:00 2001 From: firest Date: Thu, 23 Jun 2022 15:56:47 +0800 Subject: [PATCH] feat(exclusive): update schema and conf --- etc/emqx.conf | 15 +++++++++++++++ priv/emqx.schema | 5 +++-- src/emqx_exclusive_subscription.erl | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/etc/emqx.conf b/etc/emqx.conf index a4892c610..94d5cbecb 100644 --- a/etc/emqx.conf +++ b/etc/emqx.conf @@ -742,6 +742,11 @@ mqtt.wildcard_subscription = true ## Value: boolean mqtt.shared_subscription = true +## Whether the Server supports MQTT Exclusive Subscriptions. +## +## Value: boolean +mqtt.exclusive_subscription = false + ## Whether to ignore loop delivery of messages.(for mqtt v3.1.1) ## ## Value: true | false @@ -847,6 +852,11 @@ zone.external.force_gc_policy = 16000|16MB ## Value: boolean ## zone.external.shared_subscription = false +## Whether the Server supports MQTT Exclusive Subscriptions. +## +## Value: boolean +## zone.external.exclusive_subscription = false + ## Server Keep Alive ## ## Value: Number @@ -1049,6 +1059,11 @@ zone.internal.acl_deny_action = ignore ## Value: boolean ## zone.internal.shared_subscription = true +## Whether the Server supports MQTT Exclusive Subscriptions. +## +## Value: boolean +## zone.internal.exclusive_subscription = false + ## See zone.$name.max_subscriptions. ## ## Value: Integer diff --git a/priv/emqx.schema b/priv/emqx.schema index b210b9be7..b3fd916a8 100644 --- a/priv/emqx.schema +++ b/priv/emqx.schema @@ -946,8 +946,8 @@ end}. ]}. %% @doc Whether the Server supports Exclusive Subscriptions. -{mapping, "mqtt.shared_subscription", "emqx.exclusive_subscription", [ - {default, true}, +{mapping, "mqtt.exclusive_subscription", "emqx.exclusive_subscription", [ + {default, false}, {datatype, {enum, [true, false]}} ]}. @@ -1207,6 +1207,7 @@ end}. %% @doc Whether the Server supports Exclusive Subscriptions. {mapping, "zone.$name.exclusive_subscription", "emqx.zones", [ + {default, false}, {datatype, {enum, [true, false]}} ]}. diff --git a/src/emqx_exclusive_subscription.erl b/src/emqx_exclusive_subscription.erl index 165629a86..ab26a6bd6 100644 --- a/src/emqx_exclusive_subscription.erl +++ b/src/emqx_exclusive_subscription.erl @@ -86,7 +86,7 @@ unsubscribe(_Topic, _SubOpts) -> %%-------------------------------------------------------------------- %% Internal functions %%-------------------------------------------------------------------- -try_subscribe(Topic, ClientId) -> +try_subscribe(ClientId, Topic) -> case mnesia:wread({?TAB, Topic}) of [] -> mnesia:write(