Events are an indication of something of significance that has happened at a point in time i.e., past. When an event occurs one or more Consumers are notified. Consumers react to the event independent of the producer and other consumers.
Software architecture paradigm that promotes designing of systems as a collection of loosely coupled components that act as event producers and consumers.
EDA is an architecture paradigm promoting the production, detection, consumption of, and reaction to events. Microservices are producers and consumers of events.
Events are Asynchronous and require use of messaging technology for realization.
In this example when a new account is created, an event Account Created is produced. This event is consumed by multiple downstream components to carry out actions independently.
In this illustration Event contains only the meta-data, the consumer pulls the details by invoking an API.
API are directed commands whereas events are observable
API | EDA |
---|---|
Caller has knowledge of API | Producer doesn’t know Consumers |
Synchronous | Asynchronous |
Message = Request / Response | Message = Event data |
Relatively high coupling | Highly Decoupled & Extensible |
Centralized business logic | Business logic across components |
Easy to understand the flow | Relatively difficult to follow |
Event consumers subscribe to the events of interest & react to it. Consumers can be:
Domain Driven Design suggests using the events for modeling a domain.
Events occur naturally in all domains!! e.g., Order placed, Account created ….
Events are an integral part of the model | Bounded Context
Events are part of the Ubiquitous Language