RabbitMQ 桥接

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

    配置 RabbitMQ 桥接规则

    1. bridge.rabbit.hook.client.subscribe.1 = {"action": "on_client_subscribe", "rabbit": 1, "exchange": "direct:emq.subscription"}
    2. bridge.rabbit.hook.client.unsubscribe.1 = {"action": "on_client_unsubscribe", "rabbit": 1, "exchange": "direct:emq.unsubscription"}
    3. bridge.rabbit.hook.message.publish.1 = {"topic": "$SYS/#", "action": "on_message_publish", "rabbit": 1, "exchange": "topic:emq.$sys"}
    4. bridge.rabbit.hook.message.publish.2 = {"topic": "#", "action": "on_message_publish", "rabbit": 1, "exchange": "topic:emq.pub"}

    客户端取消订阅事件转发 RabbitMQ

    1. routing_key = unsubscribe
    2. exchange = emq.unsubscription
    3. payload = jsx:encode([Topic || {Topic, _Opts} <- TopicTable]),

    MQTT 消息确认 (Ack) 事件转发 RabbitMQ

    1. routing_key = puback
    2. exchange = emq.acked
    3. headers = [{<<"x-emq-msg-acked">>, binary, ClientId}],
    4. payload = emqx_base62:encode(Id)

    Python RabbitMQ消费者代码示例:

    https://github.com/rabbitmq/rabbitmq-tutorialsRabbitMQ 桥接 - 图2 (opens new window)

    启用 RabbitMQ 桥接插件