This article describes how to use ApsaraMQ for RocketMQ SDK and ApsaraMQ for MQTT provides the mapping between message structures and attribute fields involved in the interaction, helping you better understand and use these two products.
ApsaraMQ for MQTT Is a gateway product that targets mobile terminals. In actual message sending and receiving, it must be used with other storage products, such as ApsaraMQ for RocketMQ it is used for message storage.
If you use alone ApsaraMQ for MQTT, you don't need to pay attention to the mapping relationship provided in this article, all just follow the standard MQTT protocol specification.
ApsaraMQ for MQTT For more information, see What is ApsaraMQ for MQTT? and Terms.
Message structure mappings
ApsaraMQ for MQTT And ApsaraMQ for RocketMQ both message systems are based on the publish-subscribe model and have similar concepts. The following figure shows the differences in key concepts and mappings between message systems and the publish-subscribe model.
As shown in the preceding figure, ApsaraMQ for MQTT the Topic is in a multi-level structure, while ApsaraMQ for RocketMQ the Topic is only level 1. Therefore, ApsaraMQ for MQTT map the level -1 Topic in to ApsaraMQ for RocketMQ while level -2 and level -3 topics map to ApsaraMQ for RocketMQ Properties of message.
ApsaraMQ for RocketMQ The Message in the protocol can have custom Properties, but the current version of the MQTT protocol does not support Properties. However, to facilitate tracing the Header information and device information in the MQTT protocol, ApsaraMQ for MQTT part of the information will be mapped to the ApsaraMQ for RocketMQ to facilitate the use of ApsaraMQ for RocketMQ SDK.
ApsaraMQ for RocketMQ And ApsaraMQ for MQTT are the data serialization results of your service messages, ApsaraMQ for RocketMQ and ApsaraMQ for MQTT does not perform further encoding and decoding on service messages.
Property mappings
Currently, ApsaraMQ for MQTT and ApsaraMQ for RocketMQ the following table lists the supported property field mapping relationships. Use ApsaraMQ for RocketMQ and ApsaraMQ for MQTT can set or obtain information by reading and writing these properties during interaction with applications in the SDK.
For more information about QoS, cleanSession, topics, and Client IDs, see Terms.
Property key | Valid value | Description |
---|---|---|
qoslevel | 0, 1, 2 | ApsaraMQ for RocketMQ Send to ApsaraMQ for MQTT this property can be set when sending messages. If it is not set, the default value 1 is used. ApsaraMQ for MQTT Send to ApsaraMQ for RocketMQ can be read directly. |
cleansessionflag | true and false | ApsaraMQ for RocketMQ Send to ApsaraMQ for MQTT this parameter is set when the client subscribes to P2P messages. If it is not set, the default value "true" is used. This parameter cannot be set for other messages. ApsaraMQ for MQTT Send to ApsaraMQ for RocketMQ can be read directly. |
mqttSecondTopic | A string that indicates a specific subtopic | ApsaraMQ for RocketMQ Send to ApsaraMQ for MQTT To filter messages based on a subtopic, set this parameter. If you do not set this parameter, the default value null is used. ApsaraMQ for MQTT Send to ApsaraMQ for RocketMQ can be read directly. |
mqttRealTopic | The sub-level string that services expect message-receiving clients to display | ApsaraMQ for RocketMQ Send to ApsaraMQ for MQTT you can set this parameter for client messages. This parameter is typically used for P2P messages. If you do not set this parameter, P2P messages use a fixed Topic name by default. ApsaraMQ for MQTT Send to ApsaraMQ for RocketMQ the attribute is not found in the message. |
clientId | A string that indicates a specific client ID | Not settable, ApsaraMQ for MQTT send to ApsaraMQ for RocketMQ is used to trace the client ID of the message sender. |