MQTT 桥接
EMQX 3.1 版本后推出强大的规则引擎用于替换插件,建议您前往使用MQTT 桥接规则引擎中创建 MQTT 桥接
配置 MQTT 桥接转发和订阅主题
bridge.mqtt.aws.mountpoint = bridge/aws/${node}/
bridge.mqtt.aws.forwards = topic1/#,topic2/#
## 用于桥接的订阅主题
bridge.mqtt.aws.subscription.1.topic = cmd/topic1
## 用于桥接的订阅 qos
bridge.mqtt.aws.subscription.1.qos = 1
## 用于桥接的订阅主题
## 用于桥接的订阅 qos
bridge.mqtt.aws.subscription.2.qos = 1
MQTT 桥接转发和订阅主题说明
挂载点 Mountpoint: mountpoint 用于在转发消息时加上主题前缀,该配置选项须配合 forwards 使用,转发主题为 sensor1/hello 的消息, 到达远程节点时主题为 bridge/aws/emqx1@192.168.1.1/sensor1/hello。
订阅主题 Subscription: 本地 EMQX 通过订阅远程 MQTT Broker 的主题来将远程 MQTT Broker 上的消息同步到本地。
启用 bridge_mqtt 桥接插件
./bin/emqx_ctl plugins load emqx_bridge_mqtt
$ cd emqx1/ && ./bin/emqx_ctl bridges
bridges list # List bridges
bridges start <Name> # Start a bridge
bridges forwards <Name> # Show a bridge forward topic
bridges add-forward <Name> <Topic> # Add bridge forward topic
bridges del-forward <Name> <Topic> # Delete bridge forward topic
bridges subscriptions <Name> # Show a bridge subscriptions topic
列出全部 bridge 状态
启动指定 bridge
$ ./bin/emqx_ctl bridges start emqx
Start bridge successfully.
停止指定 bridge
$ ./bin/emqx_ctl bridges stop emqx
Stop bridge successfully.
$ ./bin/emqx_ctl bridges forwards emqx
topic: topic1/#
topic: topic2/#
添加指定 bridge 的转发主题
删除指定 bridge 的转发主题
$ ./bin/emqx_ctl bridges del-forward emqx topic3/#
Del-forward topic successfully.
列出指定 bridge 的订阅
$ ./bin/emqx_ctl bridges subscriptions emqx
topic: cmd/topic1, qos: 1
topic: cmd/topic2, qos: 1
Add-subscription topic successfully.