Message Queue for MQTT started to verify the region of a topic on December 19, 2019. Errors are reported when messages are sent and received between a Message Queue for MQTT topic in one region and a Message Queue for Apache RocketMQ topic in another region. This topic describes in detail how to correctly use Message Queue for MQTT and Message Queue for Apache RocketMQ topics to send and receive messages. If you have already used the cross-region mode, you can also make corrections according to the correction steps of topic hot migration in this topic.

Background

To use Message Queue for MQTT to send and receive messages, you need to bind a backend storage instance, which is a Message Queue instance. Currently, only Message Queue for Apache RocketMQ instances can be bound. The following figure shows the mappings between Message Queue for MQTT and Message Queue for Apache RocketMQ topics.

Subtopics at different levels can be directly added in code without the need to create them in the console. For more information, see Message structure mappings.

When you send and receive messages between Message Queue for MQTT and Message Queue for Apache RocketMQ SDKs, make sure that resources corresponding to the following parameters are in the same region:

  • clientId: the client ID, which consists of a group ID created in the Message Queue for MQTT console and a device ID. For more information, see Terms.
  • parentTopic: the parent topic created in the Message Queue for MQTT console, which maps the topic of the Message Queue for Apache RocketMQ instance.
  • endPoint: the endpoint obtained from the Instances page in the Message Queue for MQTT console.
  • instanceId: the ID of the Message Queue for MQTT instance that you purchased, which can be obtained from the Instances page in the Message Queue for MQTT console.
For example, you have purchased Message Queue for MQTT instance A and Message Queue for Apache RocketMQ instance A in the China (Hangzhou) region, bound the two instances, and created topic A and group ID A for each of the two instances in this region. You have also purchased Message Queue for MQTT instance B and Message Queue for Apache RocketMQ instance B in another region, for example, China (Shenzhen), bound the two instances, and created topic B and group ID B for each of the two instances in this region. Note that:
  • For topic A of Message Queue for MQTT instance A in China (Hangzhou), messages can be sent only to topic A of the bound Message Queue for Apache RocketMQ instance A in this region.
  • For topic B of Message Queue for MQTT instance B in China (Shenzhen), messages can be sent only to topic B of Message Queue for Apache RocketMQ instance B bound to Message Queue for MQTT instance B in this region.
Notice Do not send messages from topic A to Message Queue for Apache RocketMQ instance B in China (Shenzhen), or send messages from topic B to Message Queue for Apache RocketMQ instance A in China (Hangzhou).
The following figure shows the specific mapping.Hot migration
Note In the preceding figure, X indicates the incorrect use while √ indicates the correct use.
As shown in the preceding figure:
  • The group ID and topic created on a Message Queue for MQTT instance must be in the same region with the instance.
  • A Message Queue for MQTT instance must be bound to the Message Queue for Apache RocketMQ instance in the same region.
  • Topics in the Message Queue for MQTT and Message Queue for Apache RocketMQ instances that are bound must be in the same region.

Topic configuration procedure

For more information about how to configure a topic to send and receive messages, see Quick start guide.

Hot migration procedure

If you have sent and received messages between the Message Queue for MQTT and Message Queue for Apache RocketMQ topics, you can perform the following operations to make corrections based on your business sensitivity to message sending and receiving errors.

  • If your business is less sensitive to the errors, check the region and the Message Queue for Apache RocketMQ instance to be accessed by the Message Queue for MQTT client. Delete the improper topic, and recreate a topic with the same name in the Message Queue for Apache RocketMQ instance of the target region.
  • If your business is highly sensitive to the errors, submit a ticket to seek help from Message Queue for MQTT Customer Services.