与RabbitMQ的主题交流歧义 [英] Topic exchange ambiguity with RabbitMQ

查看:84
本文介绍了与RabbitMQ的主题交流歧义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有点困惑.我正在尝试进行主题交流,不确定是否需要什么.

I'm a little confused. I'm trying to implement topic exchanges and am not sure what is needed.

我想要几个路由键和1个主题交换(默认为amq.topic).我的钥匙是这样的:

I want to have several routing keys and 1 topic exchange (the default amq.topic). My keys would be like:

  • customer.appA.created
  • customer.appB.created
  • 客户.*.创建

我希望我的队列是持久的,但是我需要1个客户"队列还是2个appA和appB队列? 我已经知道我的出版商了; 连接,交换声明,基本发布.

I want my queue(s) to be durable, but do I need 1 'customer' queue or 2 queues for appA and appB? I have my publisher figured out; connect, exchange declare, basic publish.

但是我正在与消费者斗争.假设我要打开3个控制台,每个上述路由键都需要一个控制台.
我当前的使用者具有:连接,交换声明,队列绑定,基本消耗.这些连接到持久的客户"队列.但是,我的消息被循环轮询到每个控制台/消费者,而不使用路由键.

But I'm struggling with the consumers. Let's say I want to open 3 consoles, one for each of the aforementioned routing keys.
My current consumer has: connect, exchange declare, queue bind, basic consume. These are connected to a durable 'customer' queue. However my messages are being round-robin'ed to each console/consumer and not using the routing keys.

我的问题;

  1. 用于典型的主题交流设置;您需要多少个队列?
  2. 我的消费者是否可以仅仅通过交换绑定来摆脱困境,还是必须包括队列交互?
  3. 是否有可能通过主题交换在2个使用者中显示一条消息(或者您需要为此扇出)?

推荐答案

第一件事:交换不交付给消费者.它将消息传递到Queue以匹配路由基数.

First thing first : Exchange do not deliver to Consumer. It delivers messages to Queue for matching routing kyes.

      1. For a typical topic exchange set up; how many queues do you need?

如果您有多个消费者,那么每个消费者将需要一个队列.

If you have multiple consumer then you will need one queue for every consumer.

      2. Can my consumers get away with just exchange binding, or does it have to include queue interaction?

您需要将使用者与队列绑定,如果队列不存在,则创建并绑定.

You need to bind consumer with queue, if queue not exist then create and bind.

      3. Is it possible for a single message to appear in 2 consumers with topic exchange (or do you need fanout for that)?

是的,仅当使用者具有自己的使用者(使用相同的路由键绑定单独的队列)时,否则将采用循环方式.

YES, Only if the consumer have their own (separate queue bind with same routing key).Otherwise it will be Round Robin way.

所以最好的方法是让消费者拥有自己的队列以及所需的路由密钥... !!!

So best way is to have consumer's own queue with required routing key...!!!

这篇关于与RabbitMQ的主题交流歧义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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