tencent cloud

Message Enhancement Rule
Last updated:2026-01-30 14:59:41
Message Enhancement Rule
Last updated: 2026-01-30 14:59:41

Basic Concepts

Message enhancement rules are a configurable capability supported by the MQTT server. By setting rules, you can dynamically attach MQTT 5.0 properties to messages during publication based on configured conditions. These rules support flexible configuration and management through the console or TencentCloud API.
A message enhancement rule statement logically consists of two parts:
Conditions (Conditions): The conditions that trigger the rule, for example: when the message topic matches test/topic.
Actions (Actions): Operations performed when conditions are met, such as: adding Message Expiry Interval = 30 to the message.

Limitations and Constraints

Each cluster supports a maximum of 10 message enhancement rules. If you require additional quotas, please contact us.
Rules have priority settings, where a smaller priority value indicates a higher priority. The server executes rules in the order listed on the message enhancement rule page. Higher priority rules will override the actions of lower priority rules; if there is a conflict in rule configurations, the rule with higher priority takes precedence.
If the field content exceeds the length or size limitation after variable substitution, the server will automatically truncate the portion that exceeds the limit.

Configure Message Enhancement Rules

Creating Rules

1. Log in to the TDMQ for MQTT console > Cluster > Message Enhancement Rule, and click the Create rule button in the upper-left corner to configure message enhancement rules.
2. Fill in the basic information of the rule, matching conditions, and specific enhancement rule configurations based on actual circumstances. Refer to the filling instructions below for specific field filling. After filling, click Create Rule. If the "whether to enable this rule" option in the basic information was enabled during creation, the rule will take effect within 1 minute after creation; if not enabled during creation, it can also be enabled on the list page after the rule is created.

3. Successfully created rules can be viewed and managed on the list page; rules in the "Active" state cannot be deleted.


Rule Priority

1. Click the Adjust Priority button to modify the execution order of rules. The server will execute rules according to the current list order; if there is a conflict in rule configurations, the rule with higher priority takes precedence.
2. By dragging the

icon before each rule row, you can adjust the order.


Filling Instructions

Display Name
API Parameters
Description
Required
Example Value
Rule Name
RuleName
Set the rule name. It must comply with the naming rules: 3-64 characters, supporting Chinese characters, letters, numbers, "-", and "_".
Yes
"rule001"
Remarks
Remark
Set the rule description, which must not exceed 128 characters.
No
"Set expiration time"
Username
username
Enter a single username or a single resource expression. Supports the use of wildcards and rule variables, where "*" indicates support for all usernames.
Yes
"user*"
Client ID
clientId
Enter a single resource expression. Supports the use of wildcards and rule variables, where "*" indicates support for all clients.
Yes
"sensor*"
Topic
topic
Enter a single resource expression. Supports the use of wildcards and rule variables, where "*" indicates support for all Topics.
Yes
"home/room1/*"
Message Expiry Interval
messageExpiryInterval
Set the expiration time for messages in seconds. The value must be a positive integer within the range of 0–259200 seconds (0–72 hours), and 0 is not allowed.
No
3600 (indicating it expires after 1 hour)
Response Topic
responseTopic
Specify the response topic, which must be a valid UTF-8 string with a length not exceeding 256 characters. Wildcard characters "+" or "#" are not allowed. Supports the use of rule variable substitution.
No
"client/response/123"
Correlation Data
correlationData
The data field used to correlate requests and responses must be a valid UTF-8 string with a total size not exceeding 8KB. Supports the use of rule variable substitution.
No
"request-20251031"
User Properties
userProperty
Custom user attribute list; must be valid UTF-8 strings. Each attribute value (key-value pair) must not exceed 8KB in total size, with up to 10 user attributes allowed. Supports the use of rule variable substitution.
No
[{"key":"env","value":"production"},{"key":"version","value":"1.1.1"}]

Wildcard Substitution

Username

The username parameter supports the following wildcards:
Wildcard/Wildcard
Semantics
?
Any single character.
*
Any number of characters.

client ID

The clientId parameter supports the following wildcards:
Wildcard/Wildcard
Semantics
?
Any single character.
*
Any number of characters.

Topic

The topic parameter supports the following wildcards:
Wildcard/Wildcard
Semantics
+
Consistent with the MQTT protocol Topic Filter Wildcard.
#
Consistent with the MQTT protocol Topic Filter Wildcard.
?
Any single character.
*
Any number of characters.

Variable Substitution

Usage Instructions

Enter ${ in the input box to automatically display the system default rule variable substitution list.


Supported Parameters

Parameters that support rule variable substitution include:
topic
clientId
username
responseTopic
correlationData
userProperty
Note:
During rule execution, ${Variable} will be dynamically replaced with the corresponding real value; if the variable does not exist, it will be replaced with empty string. Please confirm the variable validity before use.

Rule Variable

Client Variable Field
Variable Name/Variable
Semantics
InstanceID
MQTT Instance ID
ClientId
MQTT Client ID
Username
MQTT Client Connection Username
Password
MQTT Client Connection Password
Clientip
MQTT Client IP Address
Certificate.Pem
PEM content of the client certificate
Certificate.ChainSn
Serial number of the certificate chain
Certificate Subject Field
Variable Name/Variable
Semantics
Certificate.Subject.Organization
Subject - Organization Name
Certificate.Subject.OrganizationalUnit
Subject - Organizational Unit
Certificate.Subject.State
Subject - State/Province
Certificate.Subject.CommonName
Subject - Common Name
Certificate.Subject.SerialNumber
Subject - Serial Number
Certificate.Subject.Title
Subject - Title
Certificate.Subject.Surname
Subject - Surname
Certificate.Subject.GivenName
Subject - Given Name
Certificate.Subject.Initials
Subject - Abbreviation
Certificate.Subject.Pseudonym
Subject - Alias
Certificate.Subject.GenerationQualifier
Subject - Generation Qualifier
Certificate.Subject.DistinguishedNameQualifier
Subject - Distinguished Name Qualifier
Certificate.Subject.Country
Subject - Country/Region Code
Issuer field
Variable Name/Variable
Semantics
Certificate.Issuer.Organization
Issuer - Organization Name
Certificate.Issuer.OrganizationalUnit
Issuer - Organizational Unit
Certificate.Issuer.State
Issuer - State/Province
Certificate.Issuer.CommonName
Issuer - Common Name
Certificate.Issuer.SerialNumber
Issuer - Serial Number
Certificate.Issuer.Title
Issuer - Title
Certificate.Issuer.Surname
Issuer - Surname
Certificate.Issuer.GivenName
Issuer - Given Name
Certificate.Issuer.Initials
Issuer - Abbreviation
Certificate.Issuer.Pseudonym
Issuer - Alias
Certificate.Issuer.GenerationQualifier
Issuer - Generation Qualifier
Certificate.Issuer.DistinguishedNameQualifier
Issuer - Distinguished Name Qualifier
Certificate.Issuer.Country
Issuer - Country/Region Code
Alternative Name Field
Variable Name/Variable
Semantics
Certificate.Subject.AlternativeName.RFC822Name
Subject Alternative Name - Email Address
Certificate.Subject.AlternativeName.DNSName
Subject Alternative Name - DNS Domain Name
Certificate.Subject.AlternativeName.DirectoryName
Subject Alternative Name - Directory Name
Certificate.Subject.AlternativeName.UniformResourceIdentifier
Subject Alternative Name - Uniform Resource Identifier
Certificate.Subject.AlternativeName.IPAddress
Subject Alternative Name - IP Address
Certificate.Issuer.AlternativeName.RFC822Name
Issuer Alternative Name - Email Address
Certificate.Issuer.AlternativeName.DNSName
Issuer Alternative Name - DNS Domain Name
Certificate.Issuer.AlternativeName.DirectoryName
Issuer Alternative Name - Directory Name
Certificate.Issuer.AlternativeName.UniformResourceIdentifier
Issuer Alternative Name - Uniform Resource Identifier
Certificate.Issuer.AlternativeName.IPAddress
Issuer Alternative Name - IP Address


Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback