Getting started


Publish-subscribe is a simple communication pattern where a subscriber receives messages from a publisher (and conversely a publisher sends messages to subscribers). For instance:

User (A) subscribes to the channel #news

From this point on, when a message is posted to the "#news" channel, (A) will get notified. For instance, if a publisher comes along and sends a message to the #news channel like so:

Then (A) will be notified that is received a message on #news along with a copy of the message:

Note that B doesn’t even have to know who is listening to #news. It only has to send a message where it wants the message to be seen. This sort of decoupling between "where" the information is published (the #news channel) and "how" the information is published (by reaching out to (A)) is very useful in practice.

“Instead, a popular approach to building a workflow like this is to use a publisher/subscriber (pub/sub) API or service. A pub/sub API allows a user to define a collection of queues (sometimes called topics). One or more publishers publishes messages to these queues. Likewise, one or more subscribers is listening to these queues for new messages. When a message is published, it is reliably stored by the queue and subsequently delivered to subscribers in a reliable manner.”

— Brendan Burns "Designing distributed systems" (O'Reilly)
Publisher/Subscriber infrastructure

Of course, if several users subscribe did subscribe to the #news channel, they would all have gotten a copy of the message, like so (subsequent steps on the same diagram):

If users who subscribed to the #news channel were disconnected when messages were sent, they will be able to receive their messages after reconnecting.

Find out how to subscribe and publish to #channels as described above, and then how to publish by geolocation by following the walk-through for you language’s SDK: