RabbitMQ 桥接
EMQX 3.1 版本后推出强大的规则引擎用于替换插件,建议您前往使用RabbitMQ 桥接规则引擎中创建 RabbitMQ 桥接
配置 RabbitMQ 桥接规则
bridge.rabbit.hook.client.subscribe.1 = {"action": "on_client_subscribe", "rabbit": 1, "exchange": "direct:emq.subscription"}
bridge.rabbit.hook.client.unsubscribe.1 = {"action": "on_client_unsubscribe", "rabbit": 1, "exchange": "direct:emq.unsubscription"}
bridge.rabbit.hook.message.publish.1 = {"topic": "$SYS/#", "action": "on_message_publish", "rabbit": 1, "exchange": "topic:emq.$sys"}
bridge.rabbit.hook.message.publish.2 = {"topic": "#", "action": "on_message_publish", "rabbit": 1, "exchange": "topic:emq.pub"}
客户端取消订阅事件转发 RabbitMQ
routing_key = unsubscribe
exchange = emq.unsubscription
payload = jsx:encode([Topic || {Topic, _Opts} <- TopicTable]),
MQTT 消息确认 (Ack) 事件转发 RabbitMQ
routing_key = puback
exchange = emq.acked
headers = [{<<"x-emq-msg-acked">>, binary, ClientId}],
payload = emqx_base62:encode(Id)
Python RabbitMQ消费者代码示例:
https://github.com/rabbitmq/rabbitmq-tutorials (opens new window)