- Discussion
- Useful Resources
- Quick Guide
- Blue Green Deployment
- Circuit Breaker
- Service Discovery
- External Configuration
- Health Check
- Distributed Tracing
- Performance Metrics
- Log Aggregation
- Event Sourcing
- Aysynchronous Messaging
- Saga
- Command Query Responsibility Segregator
- Shared Database per Service
- Database per Service
- Branch
- Chain Of Responsibilities
- Client Side UI Composition
- Proxy
- Aggregator
- API Gateway
- Decompose by Strangler
- Decompose by Subdomain
- Decompose by Business Capability
- Microservices Design Patterns - Overview
- Microservices Design Patterns - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Event Sourcing
Problem Statement
Microservice architecture structures an apppcation as a set of loosely coupled microservices and each service can be developed independently in agile manner to enable continous depvery/deployment and if we ve used a database per service design pattern then how to implement a transaction which spans multiple services.
Solution
We can use Event Sourcing Pattern for inter service communication. In this type of communication, each service persists the events in event store for every action taken. Each service can subscribe to these events and correspondingly updates its transaction status. Consider a case of Order Service vs Customer Service. A customer service can subscribe to events updated by order service and update its status accordingly.
Advantages
Following are the advantages of using event sourcing pattern −
Ideal for Event driven Architecture − This pattern allows to repably pubpsh events whenever a state changes.
Persistent Events − As events are persisted instead of domain objects, object-relational mismatch never happens.
Audit Log − As events captured every change, so audit logs covers 100% changes.
Entity State identification − We can create temporal queries on events database to check the current state of the entity at any point.
Monopth to Microservice architecture movement get easier − Using event sourcing pattern, we can create loosely coupled microservices which communicates via events. Thus migration from a monopth to microservice based apppcation development becomes easier.