Queue Migration
If queues are not evenly distributed across the nodes in a RabbitMQ cluster due to node scale-out or queue deletion, some nodes will be overloaded and the cluster cannot be effectively used.
To configure queue load balancing, use the following methods:
Deleting and Recreating Queues
- Log in to the RabbitMQ management UI.
- On the Overview tab page, click Download broker definitions to export the metadata.
- Stop producing messages, wait until all messages are consumed, and then delete the original queues.
- On the Overview tab page, check data consumption.
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.
- When all data is consumed, delete the original queues.
- On the Queues tab page, click the name of the desired queue.
- Click Delete Queue to delete the queue.
- On the Queues tab page, click the name of the desired queue.
- On the Overview tab page, check data consumption.
- On the Overview tab page, upload the exported metadata.
- On the Overview tab page, click Choose File and select the exported metadata.
- Click Upload broker definitions to upload the metadata.
If the upload is successful, the following information is displayed:
The instance automatically creates queues across nodes for load balancing. You can view the queue distribution details on the Queues tab page.
Modifying the Master Node Using a Policy
- Log in to the RabbitMQ management UI.
- On the Admin > Policies page, add a policy.
- Name: Enter a policy name.
- Pattern: queue matching mode. Enter a queue name. Queues with the same prefix will be matched.
- Apply to: Select Queues.
- Priority: policy priority. A larger value indicates a higher priority. This parameter is optional.
- Definition: mapping definitions. Set ha-mode to nodes and ha-params to the name of node to which the queues are to be migrated.
- Click Add policy.
- Queue data synchronization takes a long time. To prevent message loss, the original master node is still available before queue data synchronization is complete.
- After the queue switchover is complete, you can delete the policy added in 2.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.