Java – 如何在SpringCloud和RabbitMQ中实现单个发布者多个订阅者

huangapple 未分类评论58阅读模式
英文:

Java - How to have multiple subscribe from a single publisher in SpringCloud and RabbitMQ

问题

如何为单个发布者拥有多个订阅者?

例如,
已经有两条不同的消息被发布到队列中。Msg1 和 Msg2。

订阅者1 需要消费 msg1,
订阅者2 需要消费 msg2。

在 Java 中,我们如何使用 Spring Cloud Stream 和 RabbitMQ 来实现这一点?

英文:

How to have multiple subscriber for a single publisher?

For eg.
Two different message has been published to queue. Msg1 & Msg2.

Subscriber1 needs to consume msg1 and
Subscriber2 needs to consume msg2.

How can we achieve this using spring cloud stream and rabbitMQ in java?

答案1

得分: 0

你可以使用事件路由功能来实现。我们支持两种模型;路由到(特定消息处理程序/订阅者),这也是您正在寻找的,以及_路由自_。提供的链接中有示例,请仔细阅读并随时提出更具体的问题。

英文:

You can do it using Event Routing feature.
We support two models; Routing TO (specific message handler/subscriber) which is what you are looking for as well as Routing FROM. There are examples in the provided link so please go through it and feel free to follow up with more concrete question.

huangapple
  • 本文由 发表于 2020年4月8日 18:25:16
  • 转载请务必保留本文链接:https://java.coder-hub.com/61098455.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定