关于RabbitMQ 的默认交换机 的问题

实战 Java 并发编程
实战为导向,从Java 并发原理出发,并集合开发实践,全面剖析 Java 并发编程。
wangxiaoming

                                       关于RabbitMQ 的默认交换机 的问题

 

有4个默认的交换机

 

 

Name

Default pre-declared names
Direct exchange (Empty string) and amq.direct
Fanout exchange amq.fanout
Topic exchange amq.topic
Headers exchange amq.match (and amq.headers in RabbitMQ)

 

 

Default Exchange

The default exchange is a direct exchange with no name (empty string) pre-declared by the broker.

It has one special property that makes it very useful for simple applications: every queue that is created is automatically bound to it with a routing key which is the same as the queue name.

他有一个特殊的特性对简单应用很有用:每个队列会自动将一个和队列名一致的 Routing  Key 绑定到默认交换机上。

    channel.basicPublish( "", "test_fuzai_queue_1",
            MessageProperties.BASIC,
            message.getBytes());

这个代码的意思是 其实就是将 消息发送到  这个test_fuzai_queue_1队列上

但是其实第二个蚕食其实是 routingKey

For example, when you declare a queue with the name of "search-indexing-online", the AMQP 0-9-1 broker will bind it to the default exchange using "search-indexing-online" as the routing key (in this context sometimes referred to as the binding key). Therefore, a message published to the default exchange with the routing key "search-indexing-online" will be routed to the queue "search-indexing-online". In other words, the default exchange makes it seem like it is possible to deliver messages directly to queues, even though that is not technically what is happening.

 

 

要说的是没默认队列,有默认交换机,理论上每个队列能和这个默认交换机绑定,所以说没有交换机也能发送到队列

 

 

 

参考

wangxiaoming CSDN认证博客专家 架构 Spring Boot Redis
博客是很好的总结和记录工具,如果有问题,来不及回复,关注微信公众号:程序员开发者社区,获取我的联系方式,向我提问,也可以给我发送邮件,联系 1275801617@qq.com
©️2020 CSDN 皮肤主题: Age of Ai 设计师: meimeiellie 返回首页
实付0元
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值