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

RabbitMQ 的CLI管理工具 rabbitmqadmin(17)

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

可以成功发布,然后我尝试了不指定 exchange,只指定 routing_key=first ,发现报 Message published but NOT routed ,说明不指定 exchange 的情况下,系统又默认去找为空的 exchange,并且在它下面去找 routing_key=first 的binding ,但是没找到,于是信息路由不成功


fanout 的特性

定义第二个queue ,也使用 my.fanout binding 起来,取 routing_key 为 second

代码语言:javascript
复制
[root@h102 rabbitmq]# rabbitmqadmin list queues
+------+----------+
| name | messages |
+------+----------+
| test | 1        |
+------+----------+
[root@h102 rabbitmq]# rabbitmqadmin declare queue name=test.fanout durable=true
queue declared
[root@h102 rabbitmq]# rabbitmqadmin list queues
+-------------+----------+
|    name     | messages |
+-------------+----------+
| test        | 1        |
| test.fanout | 0        |
+-------------+----------+
[root@h102 rabbitmq]# rabbitmqadmin list bindings
+-----------+-------------+-------------+
|  source   | destination | routing_key |
+-----------+-------------+-------------+
|           | test        | test        |
|           | test.fanout | test.fanout |
| my.fanout | test        | first       |
+-----------+-------------+-------------+
[root@h102 rabbitmq]# 
[root@h102 rabbitmq]# rabbitmqadmin declare binding source=my.fanout destination=test.fanout routing_key=second
binding declared
[root@h102 rabbitmq]# rabbitmqadmin list bindings
+-----------+-------------+-------------+
|  source   | destination | routing_key |
+-----------+-------------+-------------+
|           | test        | test        |
|           | test.fanout | test.fanout |
| my.fanout | test        | first       |
| my.fanout | test.fanout | second      |
+-----------+-------------+-------------+
[root@h102 rabbitmq]#

尝试再发一条数据到 my.fanout

代码语言:javascript
复制
[root@h102 rabbitmq]# rabbitmqadmin list queues
+-------------+----------+
|    name     | messages |
+-------------+----------+
| test        | 1        |
| test.fanout | 0        |
+-------------+----------+
[root@h102 rabbitmq]# rabbitmqadmin publish routing_key=second exchange=my.fanout payload="just for test3"
Message published
[root@h102 rabbitmq]# rabbitmqadmin list queues
+-------------+----------+
|    name     | messages |
+-------------+----------+
| test        | 2        |
| test.fanout | 1        |
+-------------+----------+
[root@h102 rabbitmq]# rabbitmqadmin get queue=test requeue=true
+-------------+-----------+---------------+----------------+---------------+------------------+------------+-------------+
| routing_key | exchange  | message_count |    payload     | payload_bytes | payload_encoding | properties | redelivered |
+-------------+-----------+---------------+----------------+---------------+------------------+------------+-------------+
| first       | my.fanout | 1             | just for test1 | 14            | string           |            | True        |
+-------------+-----------+---------------+----------------+---------------+------------------+------------+-------------+
[root@h102 rabbitmq]# rabbitmqadmin get queue=test.fanout requeue=true
+-------------+-----------+---------------+----------------+---------------+------------------+------------+-------------+
| routing_key | exchange  | message_count |    payload     | payload_bytes | payload_encoding | properties | redelivered |
+-------------+-----------+---------------+----------------+---------------+------------------+------------+-------------+
| second      | my.fanout | 0             | just for test3 | 14            | string           |            | False       |
+-------------+-----------+---------------+----------------+---------------+------------------+------------+-------------+
[root@h102 rabbitmq]# rabbitmqadmin list queues
+-------------+----------+
|    name     | messages |
+-------------+----------+
| test        | 2        |
| test.fanout | 1        |
+-------------+----------+
[root@h102 rabbitmq]# 

本文系转载,前往查看

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

本文系转载前往查看

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

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