MQTT 桥接

    EMQX 3.1 版本后推出强大的规则引擎用于替换插件,建议您前往使用MQTT 桥接规则引擎中创建 MQTT 桥接

    配置 MQTT 桥接转发和订阅主题

    1. bridge.mqtt.aws.mountpoint = bridge/aws/${node}/
    2. bridge.mqtt.aws.forwards = topic1/#,topic2/#
    3. ## 用于桥接的订阅主题
    4. bridge.mqtt.aws.subscription.1.topic = cmd/topic1
    5. ## 用于桥接的订阅 qos
    6. bridge.mqtt.aws.subscription.1.qos = 1
    7. ## 用于桥接的订阅主题
    8. ## 用于桥接的订阅 qos
    9. 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 桥接插件

    1. ./bin/emqx_ctl plugins load emqx_bridge_mqtt
    1. $ cd emqx1/ && ./bin/emqx_ctl bridges
    2. bridges list # List bridges
    3. bridges start <Name> # Start a bridge
    4. bridges forwards <Name> # Show a bridge forward topic
    5. bridges add-forward <Name> <Topic> # Add bridge forward topic
    6. bridges del-forward <Name> <Topic> # Delete bridge forward topic
    7. bridges subscriptions <Name> # Show a bridge subscriptions topic

    列出全部 bridge 状态

    启动指定 bridge

    1. $ ./bin/emqx_ctl bridges start emqx
    2. Start bridge successfully.

    停止指定 bridge

    1. $ ./bin/emqx_ctl bridges stop emqx
    2. Stop bridge successfully.
    1. $ ./bin/emqx_ctl bridges forwards emqx
    2. topic: topic1/#
    3. topic: topic2/#

    添加指定 bridge 的转发主题

    删除指定 bridge 的转发主题

    1. $ ./bin/emqx_ctl bridges del-forward emqx topic3/#
    2. Del-forward topic successfully.

    列出指定 bridge 的订阅

    1. $ ./bin/emqx_ctl bridges subscriptions emqx
    2. topic: cmd/topic1, qos: 1
    3. topic: cmd/topic2, qos: 1
    1. Add-subscription topic successfully.

    删除指定 bridge 的订阅主题