TDMQ for MQTT provides flexible subscription management features, supporting dynamic maintenance of subscription lists: subscription addition and removal.
Add subscription: No need to reconnect to add a new subscription topic.
Remove subscription: You can remove no longer needed topic subscriptions at any time.
Application Scenario
IoT Device Management Scenario
Suitable for traditional IoT devices with difficult firmware updates.
Solve the problem of old devices being unable to reconfigure subscriptions through OTA upgrades.
Avoid device restart or reconnection caused by subscription changes.
Development and Testing Scenarios
Significantly improve development and debugging efficiency, waive frequent ROM flashing operations.
Support quick verification of message processing logic under different topics.
Make it easy to perform multi-topic parallel tests and shorten the development cycle.
Notes:
The Add Subscription and Remove Subscription TencentCloud APIs take effect in real time.
API Details
Adding a Subscription
MQTT provides TencentCloud API to add new subscriptions to sessions (Sessions) with specified Client IDs.
|
InstanceId | Instance ID | mqtt-sample |
ClientId | client ID | v-xy34213qz |
TopicFilter | Topic Filter | home/# |
QoS | Service quality, parameter values: 0, 1, 2 | 1 |
Delete Subscription
MQTT provides TencentCloud API to delete subscriptions from the Session of a specified Client ID.
|
InstanceId | Instance ID | mqtt-sample |
ClientId | client ID | v-xy34213qz |
TopicFilter | Topic Filter | home/# |
Automatic Subscription Management
Automatic subscription management is an event-driven MQTT application pattern that significantly enhances the flexibility and automation level of subscription management, suitable for IoT scenarios with highly dynamic devices and complex subscription relationships.
The complete workflow is as follows:
Device connection: An IoT device comes online and is successfully connected to the MQTT Broker.
Event trigger: Upon detecting a device connection, the MQTT Broker immediately generates a "client connected" event and publishes the event details (including metadata such as client ID, connection timestamp, and so on) to the system topic $events/client_connected.
Event listening and reception: Applications consistently subscribed to the $events/client_connected topic will receive this event notification in real time.
Subscription logic execution: The application parses the event message to obtain information such as the client ID of the newly online device, then initiates corresponding subscription management operations with the MQTT Broker on behalf of the device according to predefined business logic, such as subscribing to specific topics or unsubscribing from certain ones.
By combining client lifecycle events with subscription list management capabilities, you can easily build a flexible automatic subscription mechanism. This pattern automatically adds or modifies subscriptions based on business needs when devices connect, significantly enhancing the system's adaptive capability and operational efficiency in dynamic environments.