Overview
Syllabus
Developing Microservices with Aggregates
Presentation goal
About Chris
Microservice architecture
Domain model = tangled web of classes
Reliance on ACID transactions to enforce invariants
and requires 2PC
2PC is not an option
Domain Driven Design - building blocks
About Aggregates
Aggregate: rule #1
Domain model = collection of loosely connected aggregates
Easily partition into microservices
Aggregate rule #2
Transaction scope = service
How to maintain data consistency between aggregates?
Using event-driven Sagas instead of 2PC
Saga-based, eventually consistent order processing
Complexity of compensating transactions
How atomically update database and publish an event
Failure = inconsistent system
Event sourcing = event-centric persistence
Persists events NOT current state
Replay events to recreate state
The Customer aggregate
Customer command processing
Customer applying events
Request handling in an event sourced application
Event Store publishes events consumed by other services
Event store = database + message broker
Benefits of event sourcing
Drawbacks of event
Summary
Taught by
Devoxx