主题交易所是唯一支持通配符的交易所吗? [英] Are topic exchanges the only exchanges that support wildcards?

查看:81
本文介绍了主题交易所是唯一支持通配符的交易所吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在试图理解直接交换,扇出交换和主题交换之间的区别时,我想确认主题交换的优点是生产者推送到交换并指定了完全特定的路由键,并且队列可以绑定到多个通过通配符路由密钥.例如话题推到...

In trying to understanding the difference between direct, fanout and topic exchanges, I want to confirm that the advantage of a topic exchange is that a producer pushes to an exchange and specifies a fully specific routing key, and queues can bind to multiple routing keys via wildcards. e.g. topic pushes to...

$channel->basic_publish($msg, 'logs-exchange', 'error.critical.ram')

并且将向呼叫团队发送所有严重错误的消息的队列将绑定为...

And a queue that would message the on-call team on all critical errors would bind like...

$channel->queue_bind('on-call-team', 'logs-exchange', 'error.critical.*')

并且有一个类似 error.*.ram 的队列将通知负责增加ram的sysops团队.

And a similar queue with error.*.ram would message the sysops team responsible for increasing ram.

这是否是主题交换的正确用例,并且主题交换是唯一可以支持这种灵活性的交换吗?相反,话题交换和扇出交换都可以通过话题交换实现吗?

Is this the correct use case for a topic exchange, and is the topic exchange the only exchange that can support this flexibility? Conversely are both topic and fanout exchanges implementable by a topic exchange?

推荐答案

这是进行主题交流的正确用例吗,

Is this the correct use case for a topic exchange,

是此交易的绝对正确用法.您会看到它非常强大

Yes absolutely correct usage for this exchange. You will see that it is very powerful

主题交换是唯一可以支持这种灵活性的交换吗?

and is the topic exchange the only exchange that can support this flexibility?

是的,类似的直接交换将不支持通配符,因此在绑定到它时必须指定完整的路由密钥,否则它将无法接收消息.也许有使用主题交流作为基础的自定义消息,但我想不到一个

Yes, the direct exchange which is similar will not support wildcards so you have to specify the full routing key when you bind to it otherwise it will not receive messages. There maybe custom messages that use topic exchanges as basis but I cannot think of one off hand

相反,主题交换可以同时实现主题交换和扇出交换吗?

Conversely are both topic and fanout exchanges implementable by a topic exchange?

我不确定您的意思.是的,您可以使用相同的绑定密钥将多个队列绑定到交换,因此它们都将收到相同的消息.但是,如果您不需要该功能,则不妨使用扇出交换机本身.

I am not sure what you mean here. Yes you could have mutiple queue's bind to the exchange with the same binding key, so they will all receive the same messages. But if you do not need that functionality then you might as well use the fanout exchange itself.

此外,我还具有一个绑定到某些队列的扇出交换和一个主题交换.进行此交换的发布者使用路由密钥,即使扇出交换不需要它,也可以将其路由到主题交换.这很好,因为它对扇出没有任何影响,因为我们引起了主题交流的问题

Additionally I have a fanout exchange that is bound to some queues and a topic exchange. The publisher to this exchange uses a routing key, even though it is not needed for the fanout exchange it is needed for the topic exchange that it gets routed to. This is good because it has no effect on the fanout with our causing problems for the topic exchanges

这篇关于主题交易所是唯一支持通配符的交易所吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆