Roadmap › Design Patterns (GoF + Enterprise) in C# › Module: Enterprise and Cloud Patterns
Lessons in this course (18)
16. CQRS, Outbox and Saga
Advanced★ Must knowLesson 16 of 18
CQRS — separate the write model (commands that change state, with validation and business rules) from the read model (queries optimised for display, e.g. Dapper or views). It can share one database or use separate read stores.
Transactional Outbox — to reliably publish an event when data changes, save the event in an Outbox table in the same DB transaction as the business data; a background worker publishes it to the broker and marks it sent. This avoids "saved but message lost" or "message sent but save rolled back".
Saga — manage a business transaction spanning several services (each with its own DB) as a sequence of local transactions with compensating actions on failure (orchestration via a coordinator, or choreography via events).