Who has to know whom?
Then a new service, Loyalty, joins. Watch who has to be changed.
THROUGH AN API GATEWAY
The asker names the service it wants. The gateway passes it on.
API GATEWAY
Order workflow
has to know, by name:
Payment
Inventory
Email
+ Loyalty
Shipping
has to know, by name:
Email
Paymentanswers when asked
Inventoryanswers when asked
Loyaltyanswers when askedNEW
Emailanswers when asked
must be changed
to: Payment
answer
to: Loyalty
3
4
other services Order workflow has to know
Their names, and how to talk to each one.
Order workflow and Shipping ask. Payment, Inventory and Emailanswer. Every asker carries a list of the services it calls.
Order workflow sends a request addressed to Payment.The gateway finds Payment, but the asker still had to name it.
Payment answers. To ask, the asker had to know that Paymentexists, and exactly how it wants to be asked.
Loyalty joins. Nothing reaches it until someone calls it, soOrder workflow gets a new line on its list: it must be changed.
Only after that change does Loyalty hear about an order.Every newcomer costs a change in the services that call it.
The asker carries the list of everyone it needs.
STRENGTHOne glance at the asker shows everything itdepends on, and it gets an answer it can act on.
WEAKNESSEvery newcomer, and every change, meanschanging the asker.
THROUGH A MESSAGE BUS
Everyone knows topics on the bus. Nobody knows each other.
MESSAGE BUS
Order placed
the bus keeps no list:
it never knows who listens
Parcel sent
Order workflow
announces on the bus:
Order placed
has to know, by name:
no other service
Shipping
announces on the bus:
Parcel sent
Paymentlistens: Order placed
Inventorylistens: Order placed
Loyaltylistens: Order placedNEW
Emaillistens: Parcel sent
not touched
Order placed
0
other services Order workflow has to know
It knows one topic on the bus, and that is all.
Order workflow and Shipping announce. The others listen.Every service knows only the topics it cares about.
Order workflow announces a fact: an order was placed.There is no addressee on it.
Whoever listens for that topic gets a copy.Order workflow does not know who they are, or how many.
Loyalty joins and starts listening for "Order placed". Nobodyis changed. Order workflow never learns Loyalty exists.
With the next order, Loyalty simply gets its copy too.The price: everyone now depends on what the topic means.
Everyone knows topics. Nobody knows each other.
STRENGTHA newcomer plugs in without anyonebeing touched.
WEAKNESSNobody can see who depends on a topic. Changingwhat it means can break listeners nobody knew about.
orange = "has to know", and the list that holds it
a connection
cyan = shared infrastructure