且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

RabbitMQ 队列可以有多个订阅者吗?

更新时间:2023-12-01 21:19:16

是的,您可以,但如果控制台应用程序使用来自同一队列的消息,它们就会相互竞争.所以队列中的消息只会被其中之一消费.

Yes you can but if the console applications are consuming messages from the same queue, they are competing on each other. So the messages inside the queue will be consumed only by one of those.

如果您希望有更多订阅者接收相同的消息,您需要为每个订阅者定义一个不同的队列,绑定到应该 fanout主题(不是直接).

If you want to have more subscribers that receive the same messages, you need to define a different queue per subscriber, bound to the exchange (where the messages are passing through) that should be fanout or topic (not direct).

更多信息这里这里