emqx/apps/emqx_auto_subscribe
Serge Tupchii e4d09d4ad4 feat: implement configuration and user data export/import CLI
Closes: EMQX-9203
2023-06-09 14:11:47 +03:00
..
etc feat: generate a minimized emqx.conf 2022-05-31 19:20:27 +08:00
src feat: implement configuration and user data export/import CLI 2023-06-09 14:11:47 +03:00
test refactor: move emqx_json to emqx_utils_json 2023-04-14 13:31:27 +02:00
.gitignore feat: auto subscribe, todo: test SUITE 2021-08-25 11:57:37 +08:00
README.md chore: update README for auto subscribe 2023-04-10 14:39:13 +08:00
rebar.config refactor: move emqx_json to emqx_utils_json 2023-04-14 13:31:27 +02:00

README.md

Auto Subscribe

This application can help clients automatically subscribe to topics compiled from user definitions when they connect, and the clients no longer need to send the MQTT SUBSCRIBE request.

How To Use

Add the following configuration items to the emqx.conf file

auto_subscribe {
    topics = [
        {
            topic = "c/${clientid}"
        },
        {
            topic = "client/${clientid}/username/${username}/host/${host}/port/${port}"
            qos   = 1
            rh    = 0
            rap   = 0
            nl    = 0
        }
    ]
}

This example defines two templates, all of which will be compiled into the final topic by replacing placeholders like ${clientid} ${port} with the actual values when the client connects.

Configuration

Configuration Definition

Field Definition Value Range Default
auto_subscribe Auto subscribe configuration topics topics
topics Subscription Options Subscription configurations list. See Subscription Option []

Subscription Option

Field Definition Value Range Default
topic Required. Topic template. String, placeholders supported No default value
qos Optional. Subscription QoS 0 or 1 or 2. Refer to the MQTT QoS definition 0
rh Optional. MQTT version 5.0. Whether to send retain message when a subscription is created. 0: Not send the retain message
1: Send the retain message
0
rap Optional. MQTT version 5.0. When forwarding messages, Whether to send with retain flag 0: Set retain 0
1: Keep retain flag
0
nl Optional. MQTT version 5.0. Whether the message can be forwarded to the client when published by itself 0: Forwarded to self
1: Not forwarded to self
0

Subscription Placeholders

Placeholder Definition
${clientid} Client ID
${username} Client Username
${ip} Client TCP connection local IP address
${port} Client TCP connection local Port