tencent cloud

TDMQ for MQTT

Related Agreement
개인 정보 보호 정책
데이터 개인 정보 보호 및 보안 계약
문서TDMQ for MQTT

Request Response

포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-04-01 16:37:50

Background

The MQTT 5.0 protocol introduces the Request / Response mechanism, which defines two roles: Requester and Responder.
Requester: a Publisher client that publishes messages carrying ResponseTopic and Correlation Data;
Responder: a client that subscribes to and processes messages. For messages carrying ResponseTopic and Correlation Data properties, it generates response messages (with TopicName set to ResponseTopic) and sends them back to the MQTT Server for further processing by the Requester or other subscribers based on business logic;
For MQTT v5.0 Publishers and Subscribers, Request Response can be implemented based on the protocol and business requirements. For legacy devices that only support v3.1 and v3.1.1, the Request Response proxy reply feature is needed to provide a unified approach.

Implementation Principles

If the Requester uses the v3.1 or v3.1.1 protocol, it can use message enhancement rules to dynamically add MQTT 5.0-defined properties such as Response Topic and Correlation Data on the server side;
For v3.1 and v3.1.1 Responders, after enabling automatic reply, the processing flow is as follows:

After receiving PubAck/PubComp from a low-version Responder, the server generates a reply message based on a predefined template, carrying CorrelationData, and sends it to the ResponseTopic specified by the Requester.

Usage Instructions

1. The Responder Subscriber must subscribe with QoS > 0.
2. Auto Response automatically generates and publishes response messages only for messages that remain QoS > 0 after QoS downgrade.
3. By default, the MQTT Server enables automatic reply only for MQTT v3.1 and v3.1.1 Responders. v5.0 clients should implement Request Response on their own according to the protocol specifications.
4. Automatic reply message details:
Topic Name: ResponseTopic property value of the original message
CorrelationData: Correlation Data value of the original message
Message body in JSON format, containing the following fields:
Field Name
Description
id
Stores the unique message identifier
instanceId
Instance ID
publisherClientId
Requester client identifier
subscriberClientId
Responder client identifier
subscriberUsername
Responder username
subscriberClientHost
Responder Client Host
topic
Topic Name of the original message
qos
QoS for delivery to Responder
pubProps
Properties for publishing to Responder
messageReceivedAt
Time when the MQTT Server receives the Requester Publish packet, in milliseconds since epoch

도움말 및 지원

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

피드백