简体   繁体   中英

Receiving messages from the start of a topic

So I was wondering about a problem. Consider a publisher creates a topic at 10:00 am and immediately starts publishing messages on to the topic. It notifies the consumers of creation of the topic and then they subscribe to the topic at 10:01 am. These consumers will not receive messages sent by the publishers between 10:00 am - 10:01 am. So should the messaging provider immediately discard these messages if it finds that there are no active subscribers for this topic to receive any messages. Can we provide a subscription mechanism by which consumers can specify from which point they want to receive messages, (for eg. from the start of the topic or 12/25/2011 10:00 am PST etc.)

In Publish/Subscribe messaging model, publisher does not notify creation of a topic to subscribers.

Publishers and Subscribers are loosely coupled via the topic. So a publisher will not know whether there are any subscribers or not. Messaging provider discards a publication on topic if there are no subscribers for that topic. Some messaging providers inform the publisher if there are no takers for publication. This way publisher can make a decision on whether to continue publishing or not.

Subscribers will start getting publication from the time when a subscription is created. There are two types of subscriptions, durable and non-durable. Non-durable subscriptions are the ones where publications are delivered to subscribers as long as they are active. Durable subscription is the one where publication are delivered even when the subscribers are not active.

There is concept of Retain Publication where in messaging provider retains one latest publication and delivers to subscribers who join late.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM