0

Let's say on twitter, a celebrity update her status, and it's pushed to all of her followers.

If we set up queue, where the publisher is service that fetches the celebrity's status, and the consumer are the individual followers. But with a million followers, whoever receives that message first will see the update, while others will not ? What is a common pattern to use here so that every one of her followers will see the update and not 'compete' with each other to consume the message first?

user1008636
  • 2,989
  • 11
  • 31
  • 45
  • Aren't message queues designed for asynchronous processing use cases where the publisher isn't aware of who the consumers are and also not aware of when the consumers would process the message? – Andy Dufresne Apr 29 '19 at 05:22

1 Answers1

1

I guess you are thinking of queueing system as only having the ability to make point-to-point communication, ie, producer to queue to consumer. This is partly correct. Most queueing systems have atleast two patterns:

  1. Producer-consumer: In this scenario, a message is delivered to just one consumer, ie, if there are multiple consumers, they are competing against each other to get the message from the "queue".

  2. Publish-subscribe: Here, publishers push the message on a "topic" and consumers subscribe to the topic to get messages. The consumers are not competing - each consumer gets all the messages once they have subscribed.

In your example, it's publish-subscribe pattern in action. Underlying implementation may be different, but the basic pattern is that of publish-subscribe.

Refer: https://stackoverflow.com/a/42477769/6886283

priyank-sriv
  • 1,094
  • 6
  • 12