This topic describes mappings between the message structures and properties involved in interaction with ApsaraMQ for MQTT by using the ApsaraMQ for RocketMQ SDK, helping you better understand and use ApsaraMQ for MQTT and Message Queue for Apache RocketMQ.

ApsaraMQ for MQTT is a gateway service that is intended for mobile devices. ApsaraMQ for MQTT can interact with other Alibaba Cloud services such as ApsaraMQ for RocketMQ based on data interaction rules. For more information, see Manage rules.

If you use ApsaraMQ for MQTT independently, ignore the mappings described in this topic and observe the Message Queuing Telemetry Transport (MQTT) protocol.

For more information about ApsaraMQ for MQTT, see What is ApsaraMQ for MQTT? and Terms.

Message structure mappings

ApsaraMQ for MQTT and ApsaraMQ for RocketMQ are messaging systems that are based on the publish-subscribe model and have similar concepts. The following figure shows the differences in the major concepts and mappings between them.

Message structure

ApsaraMQ for MQTT supports multi-level topics, whereas ApsaraMQ for RocketMQ supports one-level topics, as shown in the preceding figure. Therefore, a level-1 topic in ApsaraMQ for MQTT is mapped to a topic in ApsaraMQ for RocketMQ, and level-2 and level-3 topics in ApsaraMQ for MQTT are mapped to the message properties in ApsaraMQ for RocketMQ.

The ApsaraMQ for RocketMQ protocol supports messages with custom properties, whereas the MQTT protocol does not support properties. However, part of the information in ApsaraMQ for MQTT is mapped to message properties in ApsaraMQ for RocketMQ. This facilitates tracing of the headers and device information in the MQTT protocol and allows users of the ApsaraMQ for RocketMQ SDK to retrieve such information.

Note For information about how to configure mappings from properties in ApsaraMQ for RocketMQ to parameters in ApsaraMQ for MQTT, see the table in Property mappings.

ApsaraMQ for RocketMQ and ApsaraMQ for MQTT use the data serialization results of your service messages as the payload. ApsaraMQ for RocketMQ and ApsaraMQ for MQTT do not further encode and decode the service messages.

Property mappings

The following table lists the property mappings supported between ApsaraMQ for MQTT and ApsaraMQ for RocketMQ. You can set or retrieve information by reading and writing these properties during interaction between applications that use the ApsaraMQ for RocketMQ and ApsaraMQ for MQTT SDKs.

For more information about QoS, cleanSession, topics, and client IDs, see Terms.

ApsaraMQ for MQTT parameterMessage Queue for Apache RocketMQ property keyValid property valueDescription
QoSqoslevel0, 1, and 2

This property can be set when ApsaraMQ for RocketMQ sends messages to ApsaraMQ for MQTT. If it is not set, the default value 1 is used.

ApsaraMQ for RocketMQ can directly read the QoS parameter from the messages that are sent from ApsaraMQ for MQTT.

cleanSessioncleansessionflagtrue and false

This property can be set when ApsaraMQ for RocketMQ sends P2P messages to ApsaraMQ for MQTT clients. If it is not set, the default value true is used.

This property cannot be set for other message types. ApsaraMQ for RocketMQ can directly read the cleanSession parameter from the messages that are sent from ApsaraMQ for MQTT.

SubtopicmqttSecondTopicA string that indicates a specific subtopic

This property can be set when a subtopic is required to filter the messages that ApsaraMQ for RocketMQ sends to ApsaraMQ for MQTT clients. If it is not set, the default value null is used.

ApsaraMQ for RocketMQ can directly read the subtopic from the messages that are sent from ApsaraMQ for MQTT.

Topic in messages received on a clientmqttRealTopicThe sub-level string that services expect message-receiving clients to display

This property can be set when a ApsaraMQ for MQTT client is expected to display the specified subtopic name after it receive messages from ApsaraMQ for RocketMQ. This property is typically applied to P2P messages. If it is not set, P2P messages use a fixed topic name by default.

The messages that ApsaraMQ for MQTT sends to ApsaraMQ for RocketMQ do not contain the corresponding parameter.

clientIdclientIdA string that indicates a specific client IDThis property cannot be set. When a ApsaraMQ for MQTT client sends a message to ApsaraMQ for RocketMQ, the clientId parameter is used to trace the ID of the client.