RabbitMQ 的CLI管理工具 rabbitmqadmin(19)
2023-03-20 14:52:13 时间
尝试分别使用 third 和 fourth 的 routing_key 来发布消息
[root@h102 rabbitmq]# rabbitmqadmin list queues
+-------------+----------+
| name | messages |
+-------------+----------+
| test | 0 |
| test.direct | 0 |
| test.fanout | 0 |
+-------------+----------+
[root@h102 rabbitmq]# rabbitmqadmin publish routing_key=third exchange=my.direct payload="just for test6"
Message published
[root@h102 rabbitmq]# rabbitmqadmin list queues
+-------------+----------+
| name | messages |
+-------------+----------+
| test | 1 |
| test.direct | 0 |
| test.fanout | 0 |
+-------------+----------+
[root@h102 rabbitmq]# rabbitmqadmin get queue=test requeue=true
+-------------+-----------+---------------+----------------+---------------+------------------+------------+-------------+
| routing_key | exchange | message_count | payload | payload_bytes | payload_encoding | properties | redelivered |
+-------------+-----------+---------------+----------------+---------------+------------------+------------+-------------+
| third | my.direct | 0 | just for test6 | 14 | string | | False |
+-------------+-----------+---------------+----------------+---------------+------------------+------------+-------------+
[root@h102 rabbitmq]# rabbitmqadmin publish routing_key=fourth exchange=my.direct payload="just for test7"
Message published
[root@h102 rabbitmq]# rabbitmqadmin list queues
+-------------+----------+
| name | messages |
+-------------+----------+
| test | 1 |
| test.direct | 1 |
| test.fanout | 0 |
+-------------+----------+
[root@h102 rabbitmq]# rabbitmqadmin get queue=test.direct requeue=true
+-------------+-----------+---------------+----------------+---------------+------------------+------------+-------------+
| routing_key | exchange | message_count | payload | payload_bytes | payload_encoding | properties | redelivered |
+-------------+-----------+---------------+----------------+---------------+------------------+------------+-------------+
| fourth | my.direct | 0 | just for test7 | 14 | string | | False |
+-------------+-----------+---------------+----------------+---------------+------------------+------------+-------------+
[root@h102 rabbitmq]#
从反馈结果来看,direct 的 exchange 就像点对点通信,fanout 的 exchange 就像是广播
topic 的特性
定义第四个queue ,使用 my.topic binding 起来
[root@h102 rabbitmq]# rabbitmqadmin purge queue name=test
queue purged
[root@h102 rabbitmq]# rabbitmqadmin purge queue name=test.direct
queue purged
[root@h102 rabbitmq]# rabbitmqadmin list queues
+-------------+----------+
| name | messages |
+-------------+----------+
| test | 0 |
| test.direct | 0 |
| test.fanout | 0 |
+-------------+----------+
[root@h102 rabbitmq]# rabbitmqadmin declare queue name=test.topic durable=true
queue declared
[root@h102 rabbitmq]# rabbitmqadmin list queues
+-------------+----------+
| name | messages |
+-------------+----------+
| test | 0 |
| test.direct | 0 |
| test.fanout | 0 |
| test.topic | 0 |
+-------------+----------+
[root@h102 rabbitmq]# rabbitmqadmin declare binding source=my.topic destination=test routing_key=*.hard.*
binding declared
[root@h102 rabbitmq]# rabbitmqadmin declare binding source=my.topic destination=test.topic routing_key=cheap.#
binding declared
[root@h102 rabbitmq]# rabbitmqadmin declare binding source=my.topic destination=test.direct routing_key=*.*.food
binding declared
[root@h102 rabbitmq]# rabbitmqadmin declare binding source=my.topic destination=test.fanout routing_key=*.*.food
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.topic | cheap.# |
+-----------+-------------+-------------+
[root@h102 rabbitmq]#
相关文章
- 金融服务领域的大数据:即时分析
- 影响大数据、机器学习和人工智能未来发展的8个因素
- 从0开始构建一个属于你自己的PHP框架
- 如何将Hadoop集成到工作流程中?这6个优秀实践必看
- SEO公司使用大数据优化其模型的5种方法
- 关于Web Workers你需要了解的七件事
- 深入理解HTTPS原理、过程与实践
- 增强分析:数据和分析的未来
- PHP协程实现过程详解
- AI专家:大数据知识图谱——实战经验总结
- 关于PHP的错误机制总结
- 利用数据分析量化协同过滤算法的两大常见难题
- 怎么做大数据工作流调度系统?大厂架构师一语点破!
- 2019大数据处理必备的十大工具,从Linux到架构师必修
- OpenCV中的KMeans算法介绍与应用
- 教大家如果搭建一套phpstorm+wamp+xdebug调试PHP的环境
- CentOS下三种PHP拓展安装方法
- Go语言HTTP Server源码分析
- Go语言HTTP Server源码分析
- 2017年4月编程语言排行榜:Hack首次进入前五十