This topic describes the mappings between message structures and properties that are involved when an application that uses an ApsaraMQ for RocketMQ SDK interacts with an application that uses an ApsaraMQ for MQTT SDK. This helps you understand and use the services.
ApsaraMQ for MQTT is a gateway service that is designed 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 about the rules, see Manage data inbound rules.
If you use only ApsaraMQ for MQTT, ignore the mappings described in this topic and follow 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 pattern and have similar concepts. The following figure shows the differences in major concepts and mappings between the messaging systems.
As shown in the preceding figure, ApsaraMQ for MQTT supports multi-level topics, whereas ApsaraMQ for RocketMQ supports one-level topics. A level-1 topic in ApsaraMQ for MQTT is mapped to a topic in ApsaraMQ for RocketMQ, and topics of other levels in ApsaraMQ for MQTT are mapped to message properties in ApsaraMQ for RocketMQ.
The ApsaraMQ for RocketMQ protocol supports messages that have custom properties, whereas the MQTT protocol does not support properties. To facilitate the tracing of headers and device information in the MQTT protocol and allow the users of ApsaraMQ for RocketMQ SDKs to retrieve such information, specific information in ApsaraMQ for MQTT is mapped to message properties in ApsaraMQ for RocketMQ.
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 business messages as the payload. ApsaraMQ for RocketMQ and ApsaraMQ for MQTT do not encode or decode the business messages.
Property mappings
The following table describes the supported property mappings between ApsaraMQ for MQTT and ApsaraMQ for RocketMQ. When an application that uses an ApsaraMQ for RocketMQ SDK interacts with an application that uses an ApsaraMQ for MQTT SDK, you can read and write properties to configure or retrieve information.
For information about QoS, cleanSession, topic, and client ID, see Terms.
ApsaraMQ for MQTT parameter | ApsaraMQ for RocketMQ property key | Valid property value | Description |
QoS | qoslevel | 0, 1, and 2. | You can configure this property when messages are sent from ApsaraMQ for RocketMQ to ApsaraMQ for MQTT. If this property is not configured, the default value 1 is used. ApsaraMQ for RocketMQ can directly read this property from messages that are sent from ApsaraMQ for MQTT. |
Topic | topic | A string that indicates a specific topic. | You cannot configure this property. This property is used to trace all topics from which messages are sent from ApsaraMQ for MQTT to ApsaraMQ for RocketMQ. |
cleanSession | cleansessionflag | true and false. | You can configure this property only when Point-to-Point (P2P) messages are sent from ApsaraMQ for RocketMQ to ApsaraMQ for MQTT. If you do not configure this property, the default value true is used. You cannot configure this property for other message types. ApsaraMQ for RocketMQ can directly read this property from messages that are sent from ApsaraMQ for MQTT. |
Subtopic | mqttSecondTopic | A string that indicates a specific subtopic. | You can configure this property only when subtopics are used to filter messages that are sent from ApsaraMQ for RocketMQ to ApsaraMQ for MQTT. If you do not configure this property, it is left empty. ApsaraMQ for RocketMQ can directly read this property from messages that are sent from ApsaraMQ for MQTT. |
Topic in messages received on a client | mqttRealTopic | The sub-level string that the business expects message-receiving clients to display. | You can configure this property only when an ApsaraMQ for MQTT client is expected to display the specified subtopic name after the client receives messages from ApsaraMQ for RocketMQ. In most cases, this property is applied to P2P messages. If you do not configure this property, P2P messages use a fixed topic name. This property is unavailable when messages are sent from ApsaraMQ for MQTT to ApsaraMQ for RocketMQ. |
clientId | clientId | A string that indicates a specific client ID. | You cannot configure this property. This property is used to trace the ID of the ApsaraMQ for MQTT client from which messages are sent to ApsaraMQ for RocketMQ. |