In a traditional request-driven architecture, Service A directly calls Service B, waits for a response, and then proceeds. In an Event-Driven Architecture (EDA), services communicate by producing and consuming Events—immutable records of something that happened (e.g., "Order Placed", "Payment Completed", "User Registered").
{ "event": "OrderPlaced", "orderId": 12345, "userId": 67890, "total": 99.99 }.The simplest pattern. A producer publishes a lightweight event, and consumers react independently. The producer doesn't know or care who consumes the event.
The event itself contains all the data the consumer needs, so the consumer doesn't need to make a callback to the producer's API.
{ "event": "UserUpdated", "userId": 123 }, the event carries the full state: { "event": "UserUpdated", "userId": 123, "name": "Alice", "email": "alice@example.com" }.Instead of storing the current state of an entity, the system stores a complete, ordered log of every event that ever happened to that entity. The current state is derived by replaying all events.
balance: $500. It stores: AccountOpened($0), Deposited($1000), Withdrew($300), Deposited($200), Withdrew($400). The balance is calculated by replaying these events.Often used alongside Event Sourcing. The system uses separate models for reading and writing data. Write operations (Commands) go through the Event Sourcing pipeline. Read operations (Queries) hit a separate, optimized read database that is asynchronously updated by consuming events.
Advantages: Extreme loose coupling, independent scalability, high resilience (if one consumer is down, events queue up and are processed when it recovers), natural audit log.
Disadvantages: Eventual consistency (consumers don't update instantly), debugging is harder (tracing an event through 10 services), ensuring exactly-once processing is extremely difficult.