问题描述
似乎可以通过主题交换来实现工作模式,扇出和过滤主题.为什么我会改用直接交换或扇出交换?
It seems like the worker pattern, fanout, and filtered topics can all be implemented with topic exchanges. Why would I ever use a direct or fanout exchange instead?
我们想在一个组织中找到我们组织中常见的模式,该模式抽象了amqp的无限灵活性(命名约定,默认设置为持久性,发送公共标头,到期等).我们应该利用不同的交换类型还是实现带有主题的所有模式?为什么?
We would like to codify common patterns found in our org in a library that abstracts the infinite flexibility of amqp (naming conventions, defaulting to durable, sending common headers, expirations etc.). Should we leverage the different exchange types or implement all patterns with topics; why?
(我们通过Spring Boot,golang和php在Java中有使用者/发布者)
(We have consumers/publishers in Java via spring boot, in golang, and in php)
推荐答案
没有什么不应该的.如果它适合您,请尝试一下!
nothing says you shouldn't. if it works for you, have fun with it!
如果您发现自己选择上述一种交换类型将无法为邮件设置一组所需的路由行为,请使用多个交换.您可以将路由从任意数量的交换路由到单个队列,也可以将路由从单个交换路由到任意数量的队列.
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.
关于不同的交易所类型(同样,来自我的电子书)
On the different exchange types (again, from my ebook)
直接:
Fanout:
和主题交流:
这篇关于为什么我不应该对所有内容使用Rabbitmq主题交换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!