1.声明
当前内容主要用于本人学习和复习之用,当前内容包括策略的配置和使用
当前主要来源为:RabbitMQ官方文档
2.查看命令
当前主要为:
- set_operator_policy (设置或者覆盖一个operator的策略)
- list_operator_policies (查看所有的operator的策略)
- clear_operator_policy(清除一个operator的策略 )
- set_policy (设置或者覆盖一个策略)
- list_policies (列出所有的策略不包括operator策略)
- clear_policy (清除一个策略)
通过ui界面查看policy和operator policy的区别
1.policy的界面
2.operator policy的界面
分析发现
- 相同点,两者都需要名称、正则参数、和数据定义
- 不同点,policy可以指定Exchange或者Exchange+Queue,而operator policy只能指定Queus
所以operator policy可以称为queue operator policy
3.测试
1.创建(或更新)一个queue operator policy(在vhost位hello的上面)
rabbitmqctl set_operator_policy --vhost hello --apply-to queues test-operator-ttl-6s ^test {'message-ttl':6000}
2.查看所有的operator policy
rabbitmqctl list_operator_policies --vhost hello
3.删除创建的operator policy
rabbitmqctl clear_operator_policy --vhost hello test-operator-ttl-6s
4.创建policy
rabbitmqctl set_policy --vhost hello --apply-to queues policy-test-max-length-200 ^test$ {'max-length':200}
5.查看policy
rabbitmqctl list_policies --vhost hello
6.删除policy
rabbitmqctl clear_policy --vhost hello policy-test-max-length-200
4.总结
1.poricy和opeartor poricy是不一样的,operator poricy只能为queue提供策略,而poricy可以为exchane和queue提供策略;主要使用为创建名称,匹配为正则,使用为json数据
2.注意一个队列中只能存在一个operator poricy和一个poricy,多个会替换上一个
以上纯属个人见解,如有问题请联系本人!