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

Message Queue 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 Message Queue for Apache RocketMQ it 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 MQTT For more information, see What is Message Queue for MQTT? and Terms.

Message structure mappings

Message Queue for MQTT And Message Queue for Apache 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.

Message Structure

As shown in the preceding figure, Message Queue for MQTT the Topic is in a multi-level structure, while Message Queue for Apache RocketMQ the Topic is only level 1. Therefore, Message Queue for MQTT map the level -1 Topic in to Message Queue for Apache RocketMQ while level -2 and level -3 topics map to Message Queue for Apache RocketMQ Properties of message.

Message Queue for Apache 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, Message Queue for MQTT part of the information will be mapped to the Message Queue for Apache RocketMQ to facilitate the use of Message Queue for Apache RocketMQ SDK.

Note In Message Queue for Apache RocketMQ attribute fields to map Message Queue for MQTT, see the following Property mappings form.

Message Queue for Apache RocketMQ And Message Queue for MQTT are the data serialization results of your service messages, Message Queue for Apache RocketMQ and Message Queue for MQTT does not perform further encoding and decoding on service messages.

Property mappings

Currently, Message Queue for MQTT and Message Queue for Apache RocketMQ the following table lists the supported property field mapping relationships. Use Message Queue for Apache RocketMQ and Message Queue 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

Message Queue for Apache RocketMQ Send to Message Queue for MQTT this property can be set when sending messages. If it is not set, the default value 1 is used.

Message Queue for MQTT Send to Message Queue for Apache RocketMQ can be read directly.

cleansessionflag true and false

Message Queue for Apache RocketMQ Send to Message Queue 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. Message Queue for MQTT Send to Message Queue for Apache RocketMQ can be read directly.

mqttSecondTopic A string that indicates a specific subtopic

Message Queue for Apache RocketMQ Send to Message Queue 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.

Message Queue for MQTT Send to Message Queue for Apache RocketMQ can be read directly.

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

Message Queue for Apache RocketMQ Send to Message Queue 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.

Message Queue for MQTT Send to Message Queue for Apache RocketMQ the attribute is not found in the message.

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