Message Driven
Asynchronous message-passing
“Reactive Systems rely on asynchronous message-passing to establish a boundary between components.” – Reactive Manifesto
When to use
Decoupling components.
Why it matters
- Isolation: Components don’t call each other directly (blocking). They leave messages.
- Load Management: Back-pressure. If A sends too fast, B can say “Stop” or buffer the messages.
Signs of Violation
- Deeply nested synchronous function calls across service boundaries.
- Tight coupling between sender and receiver.
Explanation
Problem
Direct calls couple time and space. Both sender and receiver must be there now.
Solution
Messages. “Packet of data sent to a specific destination”.
Real world analogy
Email vs Phone Call. Phone call requires both parties to be available (Coupled). Email (Message) allows the receiver to read it whenever they can.
Pros and Cons
| Pros | Cons |
|---|---|
Comparison
- Event Driven: Similar, but “Events” are broadcast (Listener decides), “Messages” are directed (Sender decides destination).
Code example
Typescript
Bad (Violation - Direct)
Good (Adherence)
PHP
Good (Adherence)