Migrating RabbitMQ Services
Scenario
To migrate RabbitMQ services from a single-node or cluster instance not on HUAWEI CLOUD (the source instance) to a RabbitMQ instance on HUAWEI CLOUD (the destination instance), you can use either of the following solutions:
- Solution 1: Migrate production applications and then consumption applications. No data migration is involved.
- Solution 2: Migrate data and then production and consumption applications.
Solution 1: Migrate Production Applications and Then Consumption Applications
Migrate the production applications to the destination instance. New messages are no longer published to the source instance, and consumer applications consume messages from both the source and destination instances. After all messages in the source instance are consumed, migrate the consumption applications to the destination instance.
- Messages may not be ordered consistently.
- Ensure that the client and the destination instance can be connected.
Check whether all messages in the source instance have been consumed by using the RabbitMQ Management UI or by calling an API:
- Using the RabbitMQ Management UI, as shown in Figure 1.
On the Overview tab page, if the number of messages that can be consumed (Ready) and the number of messages that are not acknowledged (Unacked) are both 0, the consumption is complete.
- Using an API
curl -s -u username:password -XGET http://ip:port/api/overview
Parameter description:
- username: account used to log in to the RabbitMQ Management UI for the source instance
- password: password used to log in to the RabbitMQ Management UI for the source instance
- ip: IP address used to log in to the RabbitMQ Management UI for the source instance
- port: port used to log in to the RabbitMQ Management UI for the source instance
When the values of messages_ready and messages_unacknowledged in the command output are both 0, the consumption is complete.
Figure 2 Command output
Solution 2: Migrate Data and Then Production and Consumption Applications
Enable the rabbitmq_shovel plug-in for both the source and destination instances. For details about how to enable the plug-in for the destination instance, see Enabling Plug-ins. Then, configure the rabbitmq_shovel plug-in for the source instance on the RabbitMQ Management UI. Source indicates the instance not on HUAWEI CLOUD, and Destination indicates the HUAWEI CLOUD RabbitMQ instance. Specify the queue on the source and the queue on the destination between which the messages are to be migrated.
After the shovel is configured, definition settings are generated for the shovel, as shown in the following figure:

If the shovel is running, the migration has started. After the data migration is complete, move the production and consumption applications to the destination RabbitMQ instance.

- In essence, a shovel migrates data by consuming messages from the source instance and re-publishing the messages to the destination instance. After the migration is complete, the source instance is drained. Stop services before the migration to avoid service interruptions.
- Ensure that the source and destination instances can be connected.
Check whether the migration is complete by using the RabbitMQ Management UI or by calling an API:
- Using the RabbitMQ Management UI, as shown in Figure 4.
On the Overview tab page, if the number of messages that can be consumed (Ready) and the number of messages that are not acknowledged (Unacked) on the source instance are both 0, the migration is complete.
You can view the data of each queue.
Figure 5 Messages in the queue on the source instance after the migration
Figure 6 Messages in the queue on the destination instance after the migration
- Using an API
curl -s -u username:password -XGET http://ip:port/api/overview
Parameter description:
- username: account used to log in to the RabbitMQ Management UI for the source instance
- password: password used to log in to the RabbitMQ Management UI for the source instance
- ip: IP address used to log in to the RabbitMQ Management UI for the source instance
- port: port used to log in to the RabbitMQ Management UI for the source instance
When the values of messages_ready and messages_unacknowledged in the command output are both 0, the migration is complete.
Figure 7 Command output


Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.