Home  >  Article  >  Backend Development  >  RabbitMQ-Introduction to mirror queue configuration

RabbitMQ-Introduction to mirror queue configuration

不言
不言forward
2019-02-28 14:24:042224browse

This article brings you an introduction to RabbitMQ-mirror queue configuration. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Set policy method

RabbitMQ-Introduction to mirror queue configuration

For example, we set the queue that satisfies the rule "*_mirrored_queue" as a mirror queue
./ rabbitmqctl set_policy -p wenda-action mirrored_queue_policy_all ".*_mirrored_queue" '{"ha-mode":"all"}'
All queues that meet the "*_mirrored_queue" rule applied after are mirrored queues

tips: Testing shows that you can set up a mirror queue using the regular rules of the policy. If the policy is not set, the mirror queue set using the x-ha-policy parameter when declaring the queue (queue_declare method) is invalid. If the policy regular rules are set and the x-ha-policy parameter is not used, the queue that meets the regular rules will automatically become a mirror queue. (Many blogs explain how to use the x-ha-policy parameter of the queue to set the mirror queue. But it does not specify that policy rules need to be created in advance).

rabbitmq documentation description:

RabbitMQ-Introduction to mirror queue configuration

#Synchronization mechanism of mirror queue

When a queue is declared as a mirror queue , and ha-mode:all, all nodes in the cluster will have a mirror of the queue. When the queue already has some data, add a new node to the cluster. After the new node joins the cluster, a mirror of the queue will be automatically created, but The queue had data before. Should the data be synchronized to the new node immediately or manually? At this time, the synchronization mechanism of the mirror queue is required.
The arg parameter in the queue_declare() method has this configuration:
ha-sync-mode manual manual synchronization | automatic automatic synchronization

tips: When a queue is being synchronized, all operations to change the queue will be blocked, which may be blocked for minutes, hours or even days due to various reasons. (So ​​be careful when synchronizing queues)

The above is the detailed content of RabbitMQ-Introduction to mirror queue configuration. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete