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

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/wangming520liwei/article/details/102585700

                                       关于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.

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

参考

猜你喜欢

转载自blog.csdn.net/wangming520liwei/article/details/102585700