为什么我不应该对所有内容都使用 rabbitmq 主题交换?
Why shouldn't I use rabbitmq topic exchanges for everything?
worker pattern、fanout、filtered topics好像都可以用topic exchange来实现。为什么我会改用直接或扇出交换?
我们想将在我们组织中发现的常见模式编纂到一个库中,该库抽象了 amqp 的无限灵活性(命名约定、默认为持久、发送常见 headers、过期等)。我们应该利用不同的交换类型还是使用主题实现所有模式;为什么?
(我们在 Java 中通过 spring 引导、golang 和 php 中有 consumers/publishers)
Why shouldn't I use rabbitmq topic exchanges for everything?
没有人说你不应该。如果它适合你,那就玩得开心吧!
The truth about exchange types is that there is no “master” type - not one to be used as a default, or most of the time. Sure, a given application may have its needs served by a single exchange or exchange type, but this will not always be the case. Even with in a single system, there may be a need to route messages in different ways and have them end up in the same queue.
If you find yourself in a situation where choosing one of the above exchange types will preclude a needed set of routing behaviors for your messages, use more than one exchange. You can route from any number of exchanges to a single queue, or from a single exchange to any number of queues.
Don’t limit your systems routing needs to a single exchange type for any given message or destination. Take advantage of each one, as needed.
关于不同的交换类型(同样来自我的电子书)
直接:
A direct exchange allows you to bind a queue to an exchange with a routing key that is matched, case sensitively. This may be the most straight-forward exchange of them all, as there is no pattern matching or other behavior to track and consider. If a routing key from a message matches the routing key of a binding in the exchange, the message is routed.
扇出:
Fanout exchanges allow you to broadcast a message to every queue bound to an exchange, with no way to filter which queues receive the message. If a queue is bound to a fanout exchange, it will receive any message published through that exchange.
与话题交流:
A topic exchange is similar to a direct exchange in that it uses routing keys. Unlike a direct exchange, though, the routing keys do not have to match exactly for a message to be routed. Topic exchanges allow you to specify wild-card matching of “topics” (routing keys) in your bindings. This lets you receive messages from more than one routing key and provides a level of flexibility not found in the other exchange types.
worker pattern、fanout、filtered topics好像都可以用topic exchange来实现。为什么我会改用直接或扇出交换?
我们想将在我们组织中发现的常见模式编纂到一个库中,该库抽象了 amqp 的无限灵活性(命名约定、默认为持久、发送常见 headers、过期等)。我们应该利用不同的交换类型还是使用主题实现所有模式;为什么?
(我们在 Java 中通过 spring 引导、golang 和 php 中有 consumers/publishers)
Why shouldn't I use rabbitmq topic exchanges for everything?
没有人说你不应该。如果它适合你,那就玩得开心吧!
The truth about exchange types is that there is no “master” type - not one to be used as a default, or most of the time. Sure, a given application may have its needs served by a single exchange or exchange type, but this will not always be the case. Even with in a single system, there may be a need to route messages in different ways and have them end up in the same queue.
If you find yourself in a situation where choosing one of the above exchange types will preclude a needed set of routing behaviors for your messages, use more than one exchange. You can route from any number of exchanges to a single queue, or from a single exchange to any number of queues.
Don’t limit your systems routing needs to a single exchange type for any given message or destination. Take advantage of each one, as needed.
关于不同的交换类型(同样来自我的电子书)
直接:
A direct exchange allows you to bind a queue to an exchange with a routing key that is matched, case sensitively. This may be the most straight-forward exchange of them all, as there is no pattern matching or other behavior to track and consider. If a routing key from a message matches the routing key of a binding in the exchange, the message is routed.
扇出:
Fanout exchanges allow you to broadcast a message to every queue bound to an exchange, with no way to filter which queues receive the message. If a queue is bound to a fanout exchange, it will receive any message published through that exchange.
与话题交流:
A topic exchange is similar to a direct exchange in that it uses routing keys. Unlike a direct exchange, though, the routing keys do not have to match exactly for a message to be routed. Topic exchanges allow you to specify wild-card matching of “topics” (routing keys) in your bindings. This lets you receive messages from more than one routing key and provides a level of flexibility not found in the other exchange types.