You can use the Global Replicator feature of ApsaraMQ for RocketMQ to synchronize consumer progress. This topic describes how to do this.
One-way synchronization task
Usage notes
After you enable consumer progress synchronization and turn on Automatically Update Consumer Progress, the system synchronizes the consumer progress between groups with the same name for all topic mappings between the source and destination instances every 10 seconds.
After you turn on Automatically Update Consumer Progress, the consumer progress is not synchronized if the group in the destination cluster is offline. If you use manual synchronization, the consumer progress is synchronized, regardless of whether the group is online.
Only the consumer progress of groups that subscribe to the same topics in the source and destination clusters is synchronized.
A time difference of minutes exists in the synchronization of consumer progress, which may cause duplicated messages. Make sure that message idempotence is implemented in your business code.
Procedure
Log on to the ApsaraMQ for RocketMQ console.
In the top navigation bar, select the region where the synchronization task that you want to manage resides, such as China (Hangzhou).
In the left-side navigation pane, click Global Replicator. On the page that appears, find the task you want to manage.
In the left-side navigation pane of the Basic Task Information page, click Consumer Progress Synchronization.
Turn on Consumer Progress Synchronization.
Select either automatic or manual synchronization.
Auto Sync
Turn on Automatically Update Consumer Progress to enable automatic synchronization. The first time you turn on Consumer Progress Synchronization, Automatically Update Consumer Progress is automatically turned on.
Manual synchronization
Turn off Automatically Update Consumer Progress and click Quick Synchronization. In the Quick Synchronization message, click OK.
Two-way synchronization task
Usage notes
After you enable consumer progress synchronization, the consumer progress is not automatically synchronized. You can manually synchronize it when exceptions occur in business to reduce the number of messages that are repeatedly consumed.
You can manually synchronize the consumer progress of the destination cluster to the source cluster only if the following conditions are met: Both the source and destination clusters are consuming messages, and the consumer progress of the source cluster is slower than that of the destination cluster.
Only the consumer progress of groups that subscribe to the same topics in the source and destination clusters is synchronized.
A time difference of minutes exists in the synchronization of consumer progress, which may cause duplicated messages. Make sure that message idempotence is implemented in your business code.
Procedure
Log on to the ApsaraMQ for RocketMQ console.
In the top navigation bar, select the region where the synchronization task that you want to manage resides, such as China (Hangzhou).
In the left-side navigation pane, click Global Replicator. On the page that appears, find the task you want to manage.
In the left-side navigation pane of the Basic Task Information page, click Consumer Progress Synchronization.
Turn on Consumer Progress Synchronization.
If you want to switch the synchronization direction, click Switch Synchronization Direction. In the Switch Synchronization Direction message, click OK.
Click Quick Synchronization. In the Quick Synchronization message, click OK.