Define RabbitMQ policies in configuration file

前端 未结 5 994
清歌不尽
清歌不尽 2021-02-02 12:50

I\'d like to define mirroring for all my queues by default. I currently have to use rabbitmqctl once the node is up:

rabbit         


        
5条回答
  •  梦谈多话
    2021-02-02 13:47

    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  

提交回复
热议问题