This topic describes message routers and message router management tasks, helping you synchronize messages for data consistency across regions based on your needs.
What is a message router?
Message routers of Message Queue for Apache RocketMQ are often used to synchronize all messages or the messages filtered by filtering rules, such as by a specific tag, to ensure data consistency across different regions. Relying on Express Connect developed by Alibaba Cloud based on its superb infrastructure (you do not need to activate Express Connect separately), the message routers of Message Queue for Apache RocketMQ allow you to efficiently synchronize messages from region to region. The following figure shows the implementation.
- Relay message routing is not supported. For example, messages cannot be synchronized from region A to region B and then to region C. If needed, create a direct route from region A to region C.
- Currently, message routers are not supported in the Internet region.
- The source topic and the target topic must have the same message type. If the message type of the source topic is normal message, that of the target topic must also be normal message.
- Considering the number of messages to be synchronized and the network bandwidth bottleneck, message synchronization may encounter latency. That is, the time when the message arrives at the target topic may be later than the time when the message enters the source topic.
Create a message router management task
You can log on to the Message Queue for Apache RocketMQ console to create a message router management task to synchronize messages across regions based on your business needs.
- Before creating a message router management task, make sure that the source and target regions of the message to be synchronized support the message router function.
- The source instance, source topic, target instance, and target topic have been created and are available. The source topic and the target topic have the same message type.
For more information about how to create an instance and a topic, see the procedure for creating a resource in Quick start for Alibaba Cloud accounts or Quick start for RAM users according to the type of your account.
- Log on to the .
- In the left-side navigation pane, click Global Message Routing.
- On the Global Message Routing page, click Create Task in the upper-right corner.
- In the Create Task dialog box, set parameters as needed and click OK.
The following table describes the parameters.
|Source Region||Select the source region of the instance to which the topic for the message that you want to synchronize belongs.|
|Source Instance||Select the source instance of the topic for the message that you want to synchronize.|
|Source Topic||Enter the name of the source topic of the message that you want to synchronize.|
|Destination Region||Select the target region of the instance of the topic for the message that you want to synchronize.|
|Destination Instance||Select the target instance of the topic for the message that you want to synchronize.|
|Destination Topic||Enter the name of the target topic of the message that you want to synchronize.|
|Initial Synchronization Site||Select the message synchronization offset in the message queue of the source topic. All the messages that queue up after the specified point are synchronized to the target topic. Currently, only Last Offset is supported, that is, starting synchronization from the latest message in the queue.|
|Filtering Rule||Enter the filtering rule. Only messages filtered by the rule can be synchronized. For example, you can directly enter the tag name such as TagA to filter messages by tag. For more information, see Message filtering.|
|Description||Enter specific descriptions of or remarks on the message router management task for distinguishing and recording.|
After the task is created, it is displayed in the task list on the Global Message Routing page.
Search for a task
On the Global Message Routing page, enter the source region, source instance, source topic, target region, target instance, and target topic in the and fields, and then click Search to search for the required task.
Start and stop a task
On the Global Message Routing page, find the target task and click Start or Stop in the Actions column.
- After the task is started, the status of the task changes to Running.
- After the task is stopped, the status of the task changes to Stopped.
Delete a task
Prerequisites: You must stop the task before deleting it.
On the Global Message Routing page, find the target task and click Delete in the Actions column.
Deleted tasks no longer appear in the search results.
View task details
On the Global Message Routing page, find the target task and click View Details in the Actions column to view task details and message details and edit the filtering rule. For more information, see Edit a filtering rule.
The following table describes key parameters in the Task Details section.
|Task Status||Task Status can be Pending, Running, or Stopped.|
|Sync TPS||The TPS value of messages transmitted per second in message synchronization, measured once a minute.|
|Message Delay||The time difference between the latest synchronization offset and the latest message offset.|
|Message Accumulation Amount||The number of messages that have not been synchronized yet.|
|Latest Sync Time||The time when the last message synchronization occurred.|
Edit a filtering rule
Prerequisites: You must stop the task before editing the filtering rule.
In the Filter Rule field of the Task Details section, click the edit icon to edit the filtering rule.