前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >RabbitMQ 的CLI管理工具 rabbitmqadmin(20)

RabbitMQ 的CLI管理工具 rabbitmqadmin(20)

作者头像
franket
发布2021-11-26 09:41:13
3590
发布2021-11-26 09:41:13
举报
文章被收录于专栏:技术杂记

如果不使用 * 和 # ,那么 topic 的特性就和 direct 一样了

代码语言:javascript
复制
[root@h102 rabbitmq]# rabbitmqadmin declare binding source=my.topic destination=test.fanout routing_key=xtest
binding declared
[root@h102 rabbitmq]# rabbitmqadmin list bindings
+-----------+-------------+-------------+
|  source   | destination | routing_key |
+-----------+-------------+-------------+
|           | test        | test        |
|           | test.direct | test.direct |
|           | test.fanout | test.fanout |
|           | test.topic  | test.topic  |
| my.direct | test        | third       |
| my.direct | test.direct | fourth      |
| my.fanout | test        | first       |
| my.fanout | test.fanout | second      |
| my.topic  | test        | *.hard.*    |
| my.topic  | test.direct | *.*.food    |
| my.topic  | test.fanout | *.*.food    |
| my.topic  | test.fanout | xtest       |
| my.topic  | test.topic  | cheap.#     |
+-----------+-------------+-------------+
[root@h102 rabbitmq]#

尝试使用以上 routing_key 发送消息

代码语言:javascript
复制
[root@h102 rabbitmq]# rabbitmqadmin list queues
+-------------+----------+
|    name     | messages |
+-------------+----------+
| test        | 0        |
| test.direct | 0        |
| test.fanout | 0        |
| test.topic  | 0        |
+-------------+----------+
[root@h102 rabbitmq]# rabbitmqadmin publish routing_key=a.hard.b  exchange=my.topic payload="just for test8"
Message published
[root@h102 rabbitmq]# rabbitmqadmin list queues
+-------------+----------+
|    name     | messages |
+-------------+----------+
| test        | 1        |
| test.direct | 0        |
| test.fanout | 0        |
| test.topic  | 0        |
+-------------+----------+
[root@h102 rabbitmq]# rabbitmqadmin publish routing_key=a.hard.food  exchange=my.topic payload="just for test9"
Message published
[root@h102 rabbitmq]# rabbitmqadmin list queues
+-------------+----------+
|    name     | messages |
+-------------+----------+
| test        | 2        |
| test.direct | 1        |
| test.fanout | 1        |
| test.topic  | 0        |
+-------------+----------+
[root@h102 rabbitmq]# rabbitmqadmin publish routing_key=cheap.soft.food  exchange=my.topic payload="just for test10"
Message published
[root@h102 rabbitmq]# rabbitmqadmin list queues
+-------------+----------+
|    name     | messages |
+-------------+----------+
| test        | 2        |
| test.direct | 2        |
| test.fanout | 2        |
| test.topic  | 1        |
+-------------+----------+
[root@h102 rabbitmq]# rabbitmqadmin publish routing_key=cheap.hard.drink  exchange=my.topic payload="just for test11"
Message published
[root@h102 rabbitmq]# rabbitmqadmin list queues
+-------------+----------+
|    name     | messages |
+-------------+----------+
| test        | 3        |
| test.direct | 2        |
| test.fanout | 2        |
| test.topic  | 2        |
+-------------+----------+
[root@h102 rabbitmq]# rabbitmqadmin publish routing_key=xtest exchange=my.topic payload="just for test12"
Message published
[root@h102 rabbitmq]# rabbitmqadmin list queues
+-------------+----------+
|    name     | messages |
+-------------+----------+
| test        | 3        |
| test.direct | 2        |
| test.fanout | 3        |
| test.topic  | 2        |
+-------------+----------+
[root@h102 rabbitmq]# rabbitmqadmin publish routing_key=cheap.hard.food  exchange=my.topic payload="just for test13"
Message published
[root@h102 rabbitmq]# rabbitmqadmin list queues
+-------------+----------+
|    name     | messages |
+-------------+----------+
| test        | 4        |
| test.direct | 2        |
| test.fanout | 4        |
| test.topic  | 3        |
+-------------+----------+
[root@h102 rabbitmq]# rabbitmqadmin list queues
+-------------+----------+
|    name     | messages |
+-------------+----------+
| test        | 4        |
| test.direct | 3        |
| test.fanout | 4        |
| test.topic  | 3        |
+-------------+----------+
[root@h102 rabbitmq]# 

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档