在 RabbitMQ 中使用配置文件定义队列 [英] Defining a queue with a config file in RabbitMQ
问题描述
有没有办法像在 ActiveMQ 中那样在配置文件中定义队列:
Is there a way to define a queue in a configuration file like in ActiveMQ :
http://activemq.apache.org/configure-startup-destinations.html
推荐答案
是的,这是可能的.
最简单的方法:
- 从 webUI 手动添加队列
默认情况下,webUI 在端口 15672 上公开.添加队列访问http://localhost:15672/#/queues
By default webUI is exposed on port 15672. Add queue accessing http://localhost:15672/#/queues
- 从 WebUI 导出配置文件.
访问主页http://localhost:15672/#/.在底部,您有导入/导出定义部分和下载代理定义按钮.
Access main page http://localhost:15672/#/. At the bottom you have section Import / export definitions, and button download broker definitions.
只需下载文件,它将包含所有定义的队列.
Just download the file and it will contain all defined queues.
示例配置文件,包含用户、虚拟主机和队列:我已经使用 JStool 插件,Notepad++ 中的 JSFormat 选项格式化了文件.默认情况下,文件是单行的,可读性不强.
Sample config file, with users, virtual host and queue: I have formatted the file using JStool plugin, JSFormat option from Notepad++. By default, file is single line and not very readable.
在下载代理定义"旁边有按钮上传代理定义".您可以上传您的文件(它可以处理格式优美的文件).
Next to 'download broker definitions' there is button 'upload broker definitions'. You may upload your file (it will work with pretty-formatted file).
{
"rabbit_version" : "3.5.7",
"users" : [{
"name" : "guest",
"password_hash" : "42234423423",
"tags" : "administrator"
}
],
"vhosts" : [ {
"name" : "/uat"
}
],
"permissions" : [{
"user" : "guest",
"vhost" : "/uat",
"configure" : ".*",
"write" : ".*",
"read" : ".*"
}
],
"parameters" : [],
"policies" : [],
"queues" : [{
"name" : "sms",
"vhost" : "/uat",
"durable" : false,
"auto_delete" : false,
"arguments" : {}
}
],
"exchanges" : [],
"bindings" : []
}
这篇关于在 RabbitMQ 中使用配置文件定义队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!