Background: I have a microservice implemented in C++ with REST and WebSocket API and pub / sub functionality. Now I need to support MQTT, and things get more complicated because my microservice must keep track of active subscriptions for scalability reasons. For example to limit deliver messages to topics and subscriptions, each client may have several own topics.
I found REST API endpoints to list subscriptions and Routes: https://docs.emqx.io/broker/v3/en/rest.html#subscriptions
https://docs.emqx.io/broker/v3/en/rest.html#routes
This would probably allow me to initiate subscriptions in my own service. What I need though is an efficient way to intercept subscriptions.
Is there a way to „subscribe“ to subscribed and unsubscribed event hooks, without having to write an extension in Erlang? E.g. forward those events to a MQTT topic which my microservice could subscribe to as MQTT client?
Emqx hooks documentation: https://docs.emqx.io/enterprise/latest/en/advanced/hooks.html
Using 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"}