English 中文(简体)
Event Sourcing
  • 时间:2024-11-03

Event Sourcing


Previous Page Next Page  

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.

Event Sourcing Pattern

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.

Advertisements