We use analytics cookies.We use cookies to analyze site traffic and improve your experience.
Loading...
System Design Masterclass · Messaging Event Systems
Free preview: the first 2 parts of this 7-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design courseread the rest of this lesson in
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design coursein Messaging Event Systems
This lesson is part of the full System Design Masterclass. Unlock it along with 769 other lessons for a one-time payment.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime Access18 Foundation lessons are free, no payment needed. Try them now
It is easy and good
“It is really nice and good Please join the course”
Picture an office with 20 departments. The HR department needs to announce a new hire. Should they walk to every single department and tell them individually? That is 19 visits. And if a new department opens next month, HR has to remember to add them to the list.
Now picture a bulletin board in the lobby. HR posts the announcement once. Every department checks the board when they walk by. Marketing sees the new hire and starts onboarding materials. IT sees it and provisions a laptop. Payroll sees it and sets up direct deposit. Nobody coordinates with each other. Nobody needs to know who else is reading.
That bulletin board is an event bus. It is a central communication channel where any component can publish events, and any other component can subscribe to the events it cares about. The publisher does not know who is listening. The subscribers do not know who published.
Event buses are everywhere, from in-process event systems in frontend frameworks (React context, Vue's event bus, Angular's EventEmitter) to distributed message buses connecting (Azure Service Bus, NServiceBus, MassTransit). The pattern is the same at every scale.
An event bus has three parts:
UserCreated { userId: "abc", email: "..." })Component A --publish--> [Event Bus] --deliver--> Handler X
Component B --publish--> --deliver--> Handler Y
Component C --publish--> --deliver--> Handler Z
In-process event bus (within a single application):
// Publisher
eventBus.publish('order.placed', { orderId: '123', amount: 99.99 });
// Subscribers (registered elsewhere)
eventBus.subscribe('order.placed', sendConfirmationEmail);
eventBus.subscribe('order.placed', updateInventory);
eventBus.subscribe('order.placed', triggerAnalytics);
The event bus maintains a mapping of event names to handler functions. When an event is published, the bus iterates through all registered handlers for that event type and invokes them.
Distributed event bus (across services):
The same concept, but the bus is an external system. , RabbitMQ, Azure Service Bus. Events travel over the network. Publishers and subscribers are separate processes, possibly on different machines. The semantics are identical. The transport changes.