背景:我有一个使用REST和WebSocket应用编程接口以及发布/订阅功能的C++实现的微服务。现在我需要支持MQTT,事情变得更加复杂,因为出于可伸缩性的原因,我的微服务必须跟踪活动订阅。例如,为了将传递消息限制为主题和订阅,每个客户端可能有几个自己的主题。
我找到了REST API端点来列出订阅和路由:https://docs.emqx.io/broker/v3/en/rest.html#subscriptions
https://docs.emqx.io/broker/v3/en/rest.html#routes
这可能会允许我在自己的服务中发起订阅。不过,我需要的是一种有效的方法来拦截订阅。
有没有一种方法可以“订阅”订阅和取消订阅的事件钩子,而不必用Erlang编写扩展?例如,将这些事件转发到我的微服务可以作为MQTT客户端订阅的MQTT主题?
Emqx钩子文档:https://docs.emqx.io/enterprise/latest/en/advanced/hooks.html
发布于 2020-05-20 13:43:06
使用emqx-web-hook:
https://github.com/emqx/emqx-web-hook
web.hook.rule.client.connect.1 = {"action": "on_client_connect"}
web.hook.rule.client.connack.1 = {"action": "on_client_connack"}
web.hook.rule.client.connected.1 = {"action": "on_client_connected"}
web.hook.rule.client.disconnected.1 = {"action": "on_client_disconnected"}
web.hook.rule.client.subscribe.1 = {"action": "on_client_subscribe"}
web.hook.rule.client.unsubscribe.1 = {"action": "on_client_unsubscribe"}
web.hook.rule.session.subscribed.1 = {"action": "on_session_subscribed"}
web.hook.rule.session.unsubscribed.1 = {"action": "on_session_unsubscribed"}
web.hook.rule.session.terminated.1 = {"action": "on_session_terminated"}
web.hook.rule.message.publish.1 = {"action": "on_message_publish"}
web.hook.rule.message.delivered.1 = {"action": "on_message_delivered"}
web.hook.rule.message.acked.1 = {"action": "on_message_acked"}https://stackoverflow.com/questions/61541202
复制相似问题