Ashwani K
Ashwani K

Reputation: 7990

How are subscribers maintained in case of topic based distributed messaging

I have following two questions related to distributed messaging system.

  1. How is topic different from Queue?
  2. How are subscribers maintained in case of topics.

Please share any document or link which can be helpful to understand these concepts. Thanks

Upvotes: 0

Views: 149

Answers (1)

Petter Nordlander
Petter Nordlander

Reputation: 22279

  1. ActiveMQ website has a pretty good explanation. Quoted here.

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. Topic subscribers, as well as queue consumers are maintained in the broker. However, subscribing clients can make the subscription durable and let the broker remember it when it goes offline. A subscriber is identified by a client id.

Upvotes: 1

Related Questions