I'd like to define mirroring for all my queues by default. I currently have to use rabbitmqctl
once the node is up:
rabbitmqctl set_policy ha-all "" '{"ha-mode":"all"}'
If one of my nodes fail, I'd have to remember to re-execute that code on restart.
Is there a way to automatically configure my node to use mirrored queues?
Defining Operator PoliciesNavigate to Admin > Policies > Add / update an operator policy. Enter "transient-queue-ttl" next to Name, "^amq\." next to Pattern, and select "Queues" next to Apply to. Enter "expires" = 1800000 in the first line next to Policy. Click Add policy.
%APPDATA%\RabbitMQ\rabbitmq. config.
config under /etc/rabbitmq directory on linux servers. Locate the rabbitmq_management tuple and change the port value (default is 12345 , change it to whatever you want). Be sure to uncomment or add the following content into /etc/rabbitmq/rabbitmq.
Policy CAN be specified in a definition file, which can be referred to from your config file.
Example of how I have set a specific policy (not sure if ha can be specified in policy):
/etc/rabbitmq/rabbitmq.config
[ {rabbit, [{vm_memory_high_watermark, 0.8}] }, {rabbitmq_management, [{listener, [{port, 15672}]}, {load_definitions, "/etc/rabbitmq/rabbitmq_definitions.json"}, {http_log_dir, "/var/log/rabbitmq/management_http.log"}] } ].
/etc/rabbitmq/rabbitmq_definitions.json
{ "users":[ {"name":"rabbot","password_hash":"Cvse5iGOg20UqUq7Za9D1tatOJnMVDru4GHtxqc02g7zj5ur","tags":""}, {"name":"rabnet","password_hash":"CqqG2fwvH6xz64NpibGJx2M7ZCyFnR1BQBM+C0KH2qRPmVxF","tags":"administrator"}], "vhosts":[ {"name":"/"}], "permissions":[ {"user":"viabot","vhost":"VIA","configure":".*","write":".*","read":".*"}, {"user":"vianet","vhost":"VIA","configure":".*","write":".*","read":".*"}], "parameters":[], "policies":[ {"vhost":"VIA","name":"DLX","pattern":".*","apply-to":"queues","definition":{"dead-letter-exchange":"dead_letter"},"priority":0} ], "queues":[ {"name":"store_to_es","vhost":"VIA","durable":true,"auto_delete":false,"arguments":{}}, {"name":"store_to_mongodb","vhost":"VIA","durable":true,"auto_delete":false,"arguments":{}} ], "exchanges":[ {"name":"data_incoming","vhost":"VIA","type":"fanout","durable":true,"auto_delete":false,"internal":false,"arguments":{}}, {"name":"sms_incoming","vhost":"VIA","type":"fanout","durable":true,"auto_delete":false,"internal":false,"arguments":{}} ], "bindings":[ {"source":"data_incoming","vhost":"VIA","destination":"store_to_es","destination_type":"queue","routing_key":"","arguments":{}}, {"source":"sms_incoming","vhost":"VIA","destination":"store_to_mongodb","destination_type":"queue","routing_key":"","arguments":{}} ] }
I am sharing this config file and definitions file as it was impossible to figure it out from the RabbitMQ web site.
Note: This config worked on RabbitMQ 3.6.1 running on Ubuntu 14.04
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With