Skip to content

Commit

Permalink
Merge pull request #2790 from emqx/auto-subs
Browse files Browse the repository at this point in the history
chore: add placeholder for auto-subscribe
  • Loading branch information
Meggielqk authored Dec 26, 2024
2 parents e986a40 + af4578c commit 04f88c8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
12 changes: 11 additions & 1 deletion en_US/messaging/mqtt-auto-subscription.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Before EMQX 5.0, this feature is called **Proxy Subscription**.

3. In the pop-up dialog box, type the test topic `a/1` in the **Topic** text box. Leave other settings as default.

- **Topic**: Type the topic that is automatically subscribed to for the client.
- **Topic**: Type the topic that is automatically subscribed to for the client. You can dynamically build the topic using placeholders. For details, see [Placeholders](#placeholders).

- **QoS**: Specify the quality of service of the topic. Options: `0`, `1`, and `2`.

Expand Down Expand Up @@ -96,3 +96,13 @@ Basic publishing and subscribing operations using [MQTTX CLI](./publish-and-subs

<img src="./assets/auto-sub-emqx_c.png" alt="auto-sub-emqx_c" style="zoom:60%;" />

## Placeholders

Auto Subscribe supports placeholders to dynamically build topics. The format of the placeholder is `${}`. The variables supported by the placeholder are:

- `${clientid}`: Client ID.
- `${username}`: Client username.
- `${host}`: IP address when the client connects to EMQX.

For example, when the client ID is `emqx_c` and the configured topic is `a/${clientid}`, the client will automatically subscribe to the topic `a/emqx_c` after connecting to EMQX.

10 changes: 9 additions & 1 deletion zh_CN/messaging/mqtt-auto-subscription.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

3. 在弹出的对话框中,在**主题**文本框中输入测试主题 `a/1`。其他设置保持默认值。

- **主题**: 输入客户端自动订阅的主题。
- **主题**: 输入客户端自动订阅的主题。您可以使用占位符动态构建主题,详见[占位符](#占位符)
- **QoS**: 指定主题的服务质量。选项:`0``1``2`
- **No local**: 选项:`False``True`
- **保留发布**: 指定是否保留使用指定主题发送的消息。选项:`False``True`
Expand Down Expand Up @@ -92,5 +92,13 @@

<img src="./assets/auto-sub-emqx_c.png" alt="auto-sub-emqx_c" style="zoom:60%;" />

## 占位符

自动订阅支持占位符来动态的构建主题。占位符的格式为 `${}`。占位符支持的变量有:

- `${clientid}`: 客户端 ID。
- `${username}`: 客户端用户名。
- `${host}`: 客户端连接到 EMQX 时的 IP 地址。

例如,当客户端 ID 为 `emqx_c`,配置主题为 `a/${clientid}` 时,客户端连接到 EMQX 后将自动订阅主题 `a/emqx_c`

0 comments on commit 04f88c8

Please # to comment.