Code Monkey home page Code Monkey logo

event-sourcing-microservices-basics's Introduction

Introduction to Event Sourcing in Microservices

This repository is a microservice reference example that is intended to teach the basics of event sourcing in Spring Boot applications.

System Architecture

For this reference, I chose to create a simple example domain with a high degree of relationships between data stored on separate microservices. In the architecture diagram below, you'll see an abstract component diagram that describes an event-driven microservice architecture containing two domain services and one aggregate processor.

Event sourcing architecture diagram

Conventions

One of the main problems I see today when describing components of a microservice architecture is a general ambiguity in the roles of separate services. For this reason, this example will describe a set of conventions for the roles of separate services.

Domain Services

Domain services are microservices that own the system of record for a portion of the application's domain.

Domain service


Domain services:

  • Manage the storage of domain data that it owns.
  • Produce the API contract for the domain data that it owns.
  • Produce events when the state of any domain data changes.
  • Maintain relationship integrity to domain data owned by other services.

Aggregate Services

Aggregate services are microservices that replicate eventually consistent views of domain data owned by separate domain services.

Aggregate service


Aggregate services:

  • Subscribe to domain events emitted by separate domain services.
  • Maintain an ordered immutable event log for events it receives.
  • Create connected query projections of distributed domain data.
  • Provide performant read-access to complex views of domain data.

Example Domain

The example domain is a social network of users who can establish friend relationships with one another. I chose this domain because it has high join complexity when the domain data is split across separate services.

Domain graph of users and friends


The diagram above is a domain graph that shows User nodes and Friend relationships. In a microservice architecture we may decide to decompose this domain graph into two separate domain services, a user-service and a friend-service. For this reason, we'll have foreign-key relationships stored in the friend-service that reference the unique identity of a User stored on the user-service.

License

This project is licensed under Apache License 2.0.

event-sourcing-microservices-basics's People

Contributors

kbastani avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.