在启动时加载 RabbitMQ 配置 [英] Load RabbitMQ config at startup
问题描述
如何在启动时加载 RabbitMQ 配置以确认代理对象(队列、交换、绑定、用户、虚拟主机、权限和参数)已创建?
How do I load a RabbitMQ config at startup to confirm that broker objects (queues, exchanges, bindings, users, virtual hosts, permissions and parameters) are created?
根据 RabbitMQ 文档,可以通过 load_definitions
http://www.rabbitmq.com/management.html#load-definitions
According to the RabbitMQ documentation, it can be done via load_definitions
http://www.rabbitmq.com/management.html#load-definitions
但是我不知道如何使用它.有人介意分享一个例子来说明这是如何工作的吗?我在网上找不到任何示例.
But I can't figure out how to use it. Would someone mind sharing an example of how this works? I can't find any examples online.
推荐答案
文档中有两个地方有待改进,这对我来说是绊脚石.
There's two bits that the documentation leaves to be desired that were stumbling blocks for me.
生成定义文件
我发现最简单的方法是配置一个你喜欢的 RabbitMQ 服务器,然后...
I found the easiest way to do that is to configure one RabbitMQ server how you like it and then...
- 进入管理网页界面
- 查看概览"选项卡/页面底部的导入/导出定义"标题
- 点击该部分中的下载代理定义"按钮
配置 RabbitMQ 以在启动时查找定义文件
- 将定义文件放在文件系统上的某个位置,以便您的 rabbitmq 守护程序将运行的用户可以读取该文件.
在配置文件中包含这样的块:
- Put the definitions file somewhere on the filesystem that it can be read by the user that your rabbitmq daemon will be running as.
Include a block like this in the configuration file:
{rabbitmq_management, [{听众,[...]},{load_definitions, "/etc/rabbitmq/definitions.json"} ]},
在启动时,这些定义应该被加载.加载它们的任何错误都应该在日志中很明显.
Upon startup, those definitions should get loaded. Any errors loading them should be apparent in the logs.
这篇关于在启动时加载 RabbitMQ 配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!