All Products
Search
Document Center

ApsaraMQ for RocketMQ:Usage notes

Last Updated:Nov 21, 2025

This topic describes how to create a Global Replicator task, and provides answers to frequently asked questions about Global Replicator to help you familiarize yourself with this feature.

Prerequisites

ApsaraMQ for RocketMQ instances are created. Applicable editions:

  • ApsaraMQ for RocketMQ V4.0 series instances.

    Note

    The Standard Edition of V4.0 series instances supports only one-way synchronization.

  • ApsaraMQ for RocketMQ V5.0 series instances.

In this topic, ApsaraMQ for RocketMQ 5.0 instances are used as the source and destination instances.

Suggestions on computing specifications

When using Global Replicator for message synchronization, additional transactions per second (TPS) overhead will be consumed. Ensure that both the source and destination ApsaraMQ for RocketMQ instances can accommodate the peak messaging TPS requirements.

Recommended TPS configurations:

For example, before synchronization, a source ApsaraMQ for RocketMQ instance may have a peak message send TPS of 10,000 and a receive TPS of 10,000.

During synchronization, we recommend allocating the following TPS resources for both the source and destination instances.

Task type

Source instance

Destination instance

Peak messaging TPS

Peak message send TPS

Peak message receive TPS

Peak messaging TPS

Peak message send TPS

Peak message receive TPS

One-way synchronization

30000

10000

20000

20000

10000

10000

Two-way synchronization

40000

20000

20000

40000

20000

20000

Note
  • View the peak messaging TPS of an instance on the Instance Details page in the ApsaraMQ for RocketMQ console. For information about the peak messaging TPS of different instance types, see Specification limits.

  • You can modify the peak message receive TPS based on the message processing rate.

Create a Global Replicator task

Note

The first time you use Global Replicator, an Alibaba Cloud Service Authorization - RocketMQ Global Replicator dialog box appears. After you click OK, the system automatically creates the AliyunServiceRoleForRMQDisasterRecovery service-linked role. ApsaraMQ for RocketMQ can assume this role to implement the Global Replicator feature. For more information, see Service-linked roles.

Step 1: Create a task

  1. Log on to the ApsaraMQ for RocketMQ console.
  2. In the left-side navigation pane, click Global Replicator. On the page that appears, click Create Task.

  3. On the Create Task page, follow the on-screen instructions to configure the parameters and click Create.

    image

    The following tables describe the parameters.

    ApsaraMQ for RocketMQ

    Parameter

    Description

    Example

    Version

    The version of the ApsaraMQ for RocketMQ instance.

    • ApsaraMQ for RocketMQ 4.0 Instance

    • ApsaraMQ for RocketMQ 5.0 Instance

    ApsaraMQ for RocketMQ 5.0 Instance

    Region

    The region where the ApsaraMQ for RocketMQ instance resides.

    China (Hangzhou)

    Instance

    The ApsaraMQ for RocketMQ instance.

    rmq-cn-778***

    Authentication Mode

    • No Configuration Required

    • ACL-based Authentication

    ACL-based Authentication

    User Name

    The username.

    yS8x01****

    Security Group ID

    The security group of the Elastic Compute Service (ECS) instance with which the ApsaraMQ for RocketMQ instance is associated. This parameter is required only if you set Version to ApsaraMQ for RocketMQ 5.0 Instance.

    • Inbound: no requirements.

    • Outbound:

      • Action: Allow

      • Protocol: Custom TCP

      • Destination: The specified CIDR blocks must include all CIDR blocks of the cluster vSwitches. The specified ports must include 8080 and 8081.

    sg-2ze4jlbqy2s40pc4****

    System Configurations of Filter Conditions

    (Optional) You can add custom attributes (UserProperty) to a message. Consumers can define subscription policies based on the SQL-92 syntax to filter messages.

    • Key: the key of UserProperty

    • Source Cluster Value: the value of UserProperty added to the message from the source cluster

    • Destination Cluster Value: the value of UserProperty added to the message from the destination cluster

    Sample code for defining subscription policies based on the SQL-92 syntax:

    String sqlStr = "{Key} IS NOT NULL AND {Key} = {Source/Destination Cluster Value}";
    consumer.subscribe(MqConfig.TOPIC, 
        MessageSelector.bySql(sqlStr));

    None

    Apache RocketMQ

    Parameter

    Description

    Example

    Access Point

    The access point. Format: {Domain name/IP address}:{Port number}.

    XX.XX.XX.XX:8080

    Authentication Mode

    • No Configuration Required

    • ACL-based Authentication

    ACL-based Authentication

    User Name

    The username. Specify the value based on the actual scenario.

    yS8x01****

    Password

    The password. Specify the value based on the actual scenario.

    F17R4to****

    Network Settings

    • Internet

    • VPC

    Internet

    Region

    The region of the ECS instance with which the Apache RocketMQ cluster is associated. This parameter is required only if you set Network Settings to VPC. The region where the Elastic Compute Service (ECS) instance on which the Apache RocketMQ cluster is deployed is located. This parameter is required only if you set Network Settings to VPC.

    China (Hangzhou)

    VPC

    The VPC of the ECS instance with which the Apache RocketMQ cluster is associated. This parameter is required only if you set Network Settings to VPC. The virtual private cloud (VPC) of the ECS instance on which the Apache RocketMQ cluster is deployed. This parameter is required only if you set Network Settings to VPC.

    vpc-bp17fapfdj0dwzjkd****

    vSwitch

    The vSwitch of the ECS instance with which the Apache RocketMQ cluster is associated. This parameter is only required if you set Network Settings to VPC. The vSwitch of the ECS instance on which the Apache RocketMQ cluster is deployed. This parameter is required only if you set Network Settings to VPC.

    vsw-bp1gbjhj53hdjdkg****

    Security Group ID

    The security group of the ECS instance with which the Apache RocketMQ cluster is associated. This parameter is required only if you set Network Settings to VPC. The security group of the ECS instance on which the Apache RocketMQ cluster is deployed.

    • Inbound: no requirements.

    • Outbound:

      • Action: Allow

      • Protocol: Custom TCP

      • Destination: The specified CIDR blocks must include all CIDR blocks where the Apache RocketMQ broker resides. The specified ports must include all ports of the Apache RocketMQ broker. The default ports are 9876, 10911, and 10909. If you changed the nameserver or the ports of the broker, specify the changed ports.

    sg-2ze4jlbqy2s40pc4****

    System Configurations of Filter Conditions

    (Optional) You can add custom attributes (UserProperty) to a message. Consumers can then define subscription policies based on the SQL-92 syntax to filter messages.

    • Key: the key of UserProperty

    • Source Cluster Value: the value of UserProperty added to the message from the source cluster

    • Destination Cluster Value: the value of UserProperty added to the message from the destination cluster

    Sample code for defining subscription policies based on the SQL-92 syntax:

    String sqlStr = "{Key} IS NOT NULL AND {Key} = {Source/Destination Cluster Value}";
    consumer.subscribe(MqConfig.TOPIC, 
        MessageSelector.bySql(sqlStr));

    None

Step 2: Configure topic mappings

  1. In the left-side navigation pane of the Basic Task Information page, click Message Synchronization.

  2. Click Batch Mapping or Add Mapping. In the dialog box that appears, configure the topic mappings.

    • Batch Mapping: Select the topic mappings. Then, click OK.

    • Add Mapping: Configure the topic mapping. Then, click OK.

    Note
    • If the source cluster is an Apache RocketMQ cluster, you must specify a group that is not in use for message synchronization.

    • Messages are synchronized only after you configure topic mappings.

(Optional) Step 3: Enable consumer progress synchronization

You can enable consumer progress synchronization to synchronize the consumer progress of a group to the destination cluster. For more information, see Consumer progress synchronization.

Description of consumer clients

In this example, a two-way synchronization task is created. In the task, an ApsaraMQ for RocketMQ instance in the China (Shanghai) region is used as the source cluster, and an ApsaraMQ for RocketMQ instance in the China (Hangzhou) region is used as the destination cluster. The Key parameter is set to Region, the Source Cluster Value parameter is set to Shanghai, and the Destination Cluster Value parameter is set to Hangzhou.

In normal cases, consumer clients residing in the China (Shanghai) region consume only messages from the ApsaraMQ for RocketMQ instance residing in the China (Shanghai) region. You need to specify only one custom attribute to match the messages. For more information, see Event patterns.

  • Subscribe to messages matching a single custom attribute

String topic = "topic";
// Subscribe to messages only in the current region. 
FilterExpression filterExpression = new FilterExpression("Region IS NOT NULL", FilterExpressionType.SQL92);
// The on-premises producer client did not specify a key whose value is Region in UserProperty during message sending. The custom attribute for the key whose value is Region is NULL.
simpleConsumer.subscribe(topic, filterExpression);
  • Subscribe to all messages in the topic

String topic = "topic";
// Subscribe to all messages. 
FilterExpression filterExpression = new FilterExpression("True", FilterExpressionType.SQL92);
simpleConsumer.subscribe(topic, filterExpression);

FAQ

Can I synchronize data across three instances?

Yes. Each Global Replicator task allows you to synchronize data between two instances. If you want to synchronize data across three instances, create three Global Replicator tasks to ensure that all messages on the instances are synchronized.

Can I use tags and SQL statements at the same time to filter messages when performing two-way synchronization on instances?

No, you can use only one of the methods to filter messages. Consumer applications use SQL statements to filter messages. We recommend using SQL statements to filter messages in instances. For more information, see Message filtering.

Can I change an existing one-way synchronization task to a two-way one?

If the source and destination clusters are both ApsaraMQ for RocketMQ instances, you can change an existing one-way synchronization task to a two-way one without affecting the running of the one-way synchronization task. If the source or destination cluster of a one-way synchronization task is an Apache RocketMQ cluster, you cannot change the task to a two-way one. You must delete it and create a two-way one.

How am I charged for using Global Replicator?

Global Replicator depends on EventBridge for message synchronization. For information about the billing of EventBridge, see Billing. Global Replicator consumes the read resources of the source ApsaraMQ for RocketMQ instance and the write resources of the destination ApsaraMQ for RocketMQ instance. When using this feature, you must evaluate the computing specifications of the ApsaraMQ for RocketMQ instances.

Why do I not receive synchronized messages after I specify access control list (ACL)-based authentication as the authentication mode?

After creating a Global Replicator task to synchronize messages, you must specify the topics whose messages you want to synchronize. Then, the system generates a group for each topic for message synchronization. The system deletes the group only if the corresponding task is deleted. If you specify ACL-based authentication as the authentication mode, you must grant the ACL user read and write permissions on the topics, and read permissions on the groups. To grant the permissions, go to the ACL Permissions tab of the Access Control page of the corresponding instance in the ApsaraMQ for RocketMQ console. When granting the permissions, you can set the Resource Name parameter to an asterisk wildcard character (*) to grant permissions on all resources to the ACL user. This reduces your configuration workload.

Can messages continue to be synchronized if the Global Replicator task is paused, then resumed?

Yes. The synchronization resumes from the next message after the latest acknowledged offset. Note that the duration for which the Global Replicator task is paused cannot exceed the message retention period in ApsaraMQ for RocketMQ.