This article describes how to use Message Queue for Apache RocketMQSDK and Message Queue for MQTTprovides the mapping between message structures and attribute fields involved in the interaction, helping you better understand and use these two products.

Message Queue for MQTTIs a gateway product that targets mobile terminals. In actual message sending and receiving, it must be used with other storage products, such as Message Queue for Apache RocketMQit is used for message storage.

If you use alone Message Queue 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.

Message Queue for MQTTFor more information, see What is MQTTand Terms.

Message structure mappings

Message Queue for MQTTAnd Message Queue for Apache RocketMQboth 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.

Message Structure

As shown in the preceding figure, Message Queue for MQTTthe Topic is in a multi-level structure, while Message Queue for Apache RocketMQthe Topic is only level 1. Therefore, Message Queue for MQTTmap the level -1 Topic in to Message Queue for Apache RocketMQwhile level -2 and level -3 topics map to Message Queue for Apache RocketMQProperties of message.

Message Queue for Apache RocketMQThe 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, Message Queue for MQTTpart of the information will be mapped to the Message Queue for Apache RocketMQto facilitate the use of Message Queue for Apache RocketMQSDK.

Note In Message Queue for Apache RocketMQattribute fields to map Message Queue for MQTT, see the following Property mappingsform.

Message Queue for Apache RocketMQAnd Message Queue for MQTTare the data serialization results of your service messages, Message Queue for Apache RocketMQand Message Queue for MQTTdoes not perform further encoding and decoding on service messages.

Property mappings

Currently, Message Queue for MQTTand Message Queue for Apache RocketMQthe following table lists the supported property field mapping relationships. Use Message Queue for Apache RocketMQand Message Queue for MQTTcan 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

Message Queue for Apache RocketMQSend to Message Queue for MQTTthis property can be set when sending messages. If it is not set, the default value 1 is used.

Message Queue for MQTTSend to Message Queue for Apache RocketMQcan be read directly.

cleansessionflag true and false

Message Queue for Apache RocketMQSend to Message Queue for MQTTthis 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. Message Queue for MQTTSend to Message Queue for Apache RocketMQcan be read directly.

mqttSecondTopic A string that indicates a specific subtopic

Message Queue for Apache RocketMQSend to Message Queue for MQTTTo filter messages based on a subtopic, set this parameter. If you do not set this parameter, the default value null is used.

Message Queue for MQTTSend to Message Queue for Apache RocketMQcan be read directly.

mqttRealTopic The sub-level string that services expect message-receiving clients to display

Message Queue for Apache RocketMQSend to Message Queue for MQTTyou 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.

Message Queue for MQTTSend to Message Queue for Apache RocketMQthe attribute is not found in the message.

clientId A string that indicates a specific client ID Not settable, Message Queue for MQTTsend to Message Queue for Apache RocketMQis used to trace the client ID of the message sender.