删除 exchange
代码语言:javascript复制[root@h102 rabbitmq]# rabbitmqadmin list exchanges
-------------------- ---------
| name | type |
-------------------- ---------
| | direct |
| amq.direct | direct |
| amq.fanout | fanout |
| amq.headers | headers |
| amq.match | headers |
| amq.rabbitmq.log | topic |
| amq.rabbitmq.trace | topic |
| amq.topic | topic |
| kk | fanout |
| test | fanout |
-------------------- ---------
[root@h102 rabbitmq]# rabbitmqadmin delete exchange name=test
exchange deleted
[root@h102 rabbitmq]# rabbitmqadmin list exchanges
-------------------- ---------
| name | type |
-------------------- ---------
| | direct |
| amq.direct | direct |
| amq.fanout | fanout |
| amq.headers | headers |
| amq.match | headers |
| amq.rabbitmq.log | topic |
| amq.rabbitmq.trace | topic |
| amq.topic | topic |
| kk | fanout |
-------------------- ---------
[root@h102 rabbitmq]#
删除 binding
代码语言:javascript复制[root@h102 rabbitmq]# rabbitmqadmin list bindings source destination_type destination properties_key
-------- ------------------ ------------- ----------------
| source | destination_type | destination | properties_key |
-------- ------------------ ------------- ----------------
| | queue | test | test |
| kk | queue | test | test |
-------- ------------------ ------------- ----------------
[root@h102 rabbitmq]# rabbitmqadmin delete binding source='kk' destination_type=queue destination=test properties_key=test
binding deleted
[root@h102 rabbitmq]# rabbitmqadmin list bindings source destination_type destination properties_key
-------- ------------------ ------------- ----------------
| source | destination_type | destination | properties_key |
-------- ------------------ ------------- ----------------
| | queue | test | test |
-------- ------------------ ------------- ----------------
[root@h102 rabbitmq]#
Note: source、 destination_type、destination、properties_key 缺一不可,否则会报错
Tip: vhost、policy、parameter、permission 的删除方法类似 ,connection 的关闭方法也类似
清空队列
代码语言:javascript复制[root@h102 rabbitmq]# rabbitmqadmin list queues
------ ----------
| name | messages |
------ ----------
| test | 5 |
------ ----------
[root@h102 rabbitmq]# rabbitmqadmin purge queue name=test
queue purged
[root@h102 rabbitmq]# rabbitmqadmin list queues
------ ----------
| name | messages |
------ ----------
| test | 0 |
------ ----------
[root@h102 rabbitmq]#