RabbitMQ - 话题交换和竞争消费者 [英] RabbitMQ - Topic Exchanges and Competing Consumers
本文介绍了RabbitMQ - 话题交换和竞争消费者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我成功设置了一个 Topic Exchange,并且能够一次向多个消费者发送消息.
I successfully setup a Topic Exchange, and I'm able to deliver messages to several consumers at once.
我还想向竞争的消费者传递消息并继续使用主题交换.我读到使用相同的队列名称可以让消费者竞争消息.但是,我可能会弄错,因为我无法让它发挥作用.
I'd also like to deliver messages to competing consumers and keep using topic exchanges. I read that using the same queue name enables consumers to compete for messages. I might be mistaken, however, since I cannot make it work.
为同一主题的多个侦听器设置:
Setup for several listeners to the same topic:
- 声明主题交换
- 对于每个侦听器,声明一个具有自动生成名称的新队列
- 使用给定的主题路由键将此队列绑定到上述交换
如何为同一主题设置竞争消费者?
How to setup competing consumers to the same topic?
话题交换是否可行?
谢谢.
推荐答案
我通过使用 exchange-to-exchange 绑定解决了这个问题.
I solved this by using exchange-to-exchange bindings.
- 外部交换是主题交换.
- 内部交换是绑定到客户端命名队列的扇出交换.
- 外部交换通过包含通配符的路由密钥绑定到内部交换.
这篇关于RabbitMQ - 话题交换和竞争消费者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文