Not Just Events: Developing Asynchronous Microservices
summary
Explains how to implement distributed transactions with sagas (local steps, compensating rollbacks) and when to use choreography vs orchestration; shows an order/customer example that uses a pending order state and a credit reservation step, sagas target tens of milliseconds. Describes atomic publish/update via transactional outbox (DB outbox table or tailing MySQL binlog / Postgres write-ahead log) and using CQRS with MongoDB/Elasticsearch for complex queries, noting typical replication lag ~20 ms and at-least-once delivery tradeoffs.
AI-written summary · about
chapters (23)
- 0:00Start
- 3:57Service = independently deployable component
- 10:09Querying across services is not straightforward
- 11:15Use Sagas instead of 2PC
- 12:51Saga design challenges
- 14:56How do the saga participants
- 18:49How to sequence the saga transactions?
- 19:49Choreography-based Create Order Saga
- 21:49Benefits and drawbacks of choreography
- 24:51Saga orchestrator behavior
- 26:18CreateOrder Saga orchestrator
- 28:16Benefits and drawbacks of orchestration Benefits
- 30:38API Composition pattern
- 34:52Command Query Responsibility Segregation (CQRS)
- 36:38Handling replication lag
- 38:39Messaging must be transactional
- 39:10Publish to message broker first?
- 42:10Event sourcing guarantees: state change = event is published
- 44:27Spring Data for JPA example
- 44:44Transactional Outbox pattern
- 45:51Transaction log tailing
- 46:33Polling the message table
- 48:28Summary
related talks
17mSaga Pattern for Distributed Transactions
51mPatterns & Practices of Implementing Event-driven MicroSvc...
58mImplementing Event-driven Microservices
47mEvent-Driven Microservices = Microservices Done Right
56mDeveloping Event-driven Microservices w/Event Sourcing and CQRS
53mEffective Microservice Communication and Conversation Patterns
27mBuilding Microservices Architecture The Right Way based on Saga Pattern
55mTackling transactions in Microservices applications
