tencent cloud

TDMQ for MQTT

Release Notes and Announcements
Release Notes
Product Introduction
TDMQ Product Series Introduction and Selection
What Is TDMQ for MQTT
Scenarios
Technical Architecture
Product series
MQTT Protocol Compatibility Notes
Comparison with Apache
High Availability
Product Constraints and Usage Quota
Basic Concepts
Supported Regions
Billing
Billing Overview
Renewal Instructions
Viewing Consumption Details
Overdue Payment Instructions
Refund
Getting Started
Guide for Getting Started
Preparations
Public Network Access
VPC Network Access
User Guide
Usage Process Guide
Configuring Account Permission
Creating a Cluster
Managing Topic
Connecting to the Cluster
Querying Messages
Managing Client
Managing a Cluster
Viewing Monitoring Metrics and Configuring Alarm Policies
Data Integration
Integrating Data Into SCF
Integrating Data Into CKafka
Integrating Data into RocketMQ
Development Guide
MQTT 5 Advanced Features
Data Plane HTTP API Description
Quota and Flow Control Mechanism Description
Configuring a Custom Domain Name
Configuring SQL Filtering
Configuring Point-to-Point Subscription
MQTT over QUIC
Managing Client Subscription
Message Enhancement Rule
Use Cases
Must-Knows for MQTT Client Development
Observability
Topic and Wildcard Subscriptions
​​API Reference
History
Introduction
API Category
Making API Requests
Cluster APIs
Topic APIs
Authorization Policy APIs
User APIs
Client APIs
Message Enhancement Rule APIs
Message APIs
Data Types
Error Codes
SDK Reference
Access Point Format
Java SDK
C SDK
Javascript/Node.JS/Mini Program
Go SDK
iOS SDK
JavaScript SDK
Dart SDK
Python SDK
.NET
Security and Compliance
Permission Management
FAQs
Related Agreement
Privacy Policy
Data Privacy And Security Agreement
TDMQ for MQTT Service Level Agreement
Contact Us
문서TDMQ for MQTTDevelopment GuideManaging Client Subscription

Managing Client Subscription

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-04-01 16:37:51
TDMQ for MQTT provides flexible subscription management features, supporting dynamic maintenance of subscription lists: subscription addition and removal.
Subscription addition: New topics can be subscribed to without reconnecting.
Subscription removal: Topic subscriptions that are no longer needed can be removed at any time.

Scenarios

IoT Device Management Scenario

Suitable for traditional IoT devices with hard-to-update firmware.
Addresses the inability to reconfigure subscriptions on legacy devices through OTA upgrades.
Avoids device restarts or reconnections caused by subscription changes.

Development and Testing Scenarios

Significantly improves development and debugging efficiency, avoiding frequent ROM flashing operations.
Supports quick verification of message processing logic under different topics.
Makes it easier to perform multi-topic parallel tests and shorten the development cycle.
Note:
TencentCloud APIs for subscription addition and removal take effect in real time.

API Details

Adding a Subscription

MQTT provides TencentCloud APIs to add new subscriptions to the session of a specified client ID.
Parameter Name
Description
Example
InstanceId
Instance ID
mqtt-sample
ClientId
Client ID
v-xy34213qz
TopicFilter
Topic Filter
home/#
QoS
Quality of Service. Valid values: 0, 1, or 2.
1

Deleting a Subscription

MQTT provides TencentCloud APIs to delete subscriptions from the session of a specified client ID.
Parameter Name
Description
Example
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 mode that significantly enhances the flexibility and automation of subscription management, making it 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 successfully connects 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: The application that consistently subscribes to the $events/client_connected topic receives 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 connected device, and 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 mode automatically adds or modifies subscriptions based on business needs during device connections, significantly enhancing the system's adaptability and operational efficiency in dynamic environments.

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백