在基于主题的分布式消息传递的情况下如何维护订阅者

How are subscribers maintained in case of topic based distributed messaging

我有以下两个与分布式消息系统相关的问题。

  1. 主题与队列有何不同?
  2. 在主题的情况下如何维护订阅者。

请分享任何有助于理解这些概念的文档或link。 谢谢

  1. ActiveMQ website 有很好的解释。此处引用。

Topics

In JMS a Topic implements publish and subscribe semantics. When you publish a message it goes to all the subscribers who are interested - so zero to many subscribers will receive a copy of the message. Only subscribers who had an active subscription at the time the broker receives the message will get a copy of the message.

Queues

A JMS Queue implements load balancer semantics. A single message will be received by exactly one consumer. If there are no consumers available at the time the message is sent it will be kept until a consumer is available that can process the message. If a consumer receives a message and does not acknowledge it before closing then the message will be redelivered to another consumer. A queue can have many consumers with messages load balanced across the available consumers. So Queues implement a reliable load balancer in JMS.

2。 主题订阅者以及队列消费者都在代理中维护。但是订阅客户端可以让订阅持久化,让broker在下线的时候记住它。订阅者由客户端 ID 标识。