Introduction

An almost trivial example of PubSub is the daily newspaper:

Once you have a subscription, you automatically get each new publication.

Typically, you are not the only subscriber; the same ‘newspaper’ is sent to all subscribers: everybody got his copy. And, whenever somebody cancels his subscription, all others still get there update daily.
Also notice: your copy is independent of that the neighbors. And, until you subscribe, the publisher does not know you.

In software-engineering, we call that uncoupled or loosely coupled, and that is great.
As we will explain in the next page.

' Copyright (C) 2020: ALbert Mietus.


@startuml
hide footbox
participant Publisher         as P
participant You               as S1
participant "Somebody"        as S2
participant "Else"  as S3

== Get your subscription ==

P //-- S1    : Subscribe to newspaper
...
[--\ P : //news//
activate P
P -> S1     : Get your copy
deactivate P

== Everybody got its own **copy** of the //same// newspaper ==


P //-- S2    : Another subscription
P //-- S3    : Another subscription

...
[--\ P : //news//
activate P
P -> S1
P -> S2
P -> S3
deactivate P

== Until it is canceled ==

P //-- S2    : unsubscribe
...
[--\ P : //news//
activate P
P -> S1
P -> S3
deactivate P


@enduml

Comments

comments powered by Disqus