- Introduction to CQRS and ES
- Separating commands from queries
- Query stack
- Command stack
- Domain events
- Persisting events
- Replaying events
Generally speaking, any actions performed on a software system belong to one of the following two categories: query or command.
The logical separation that exists between queries and commands doesn’t show up clearly if the two groups of actions are forced to use the same domain model. For this reason, a new supporting architecture emerged in the past few years called CQRS, which is short for Command/Query Responsibility Segregation.
The CQRS pattern is based on a simple, almost commonplace, idea: queries and commands (sometimes also referred to as reads and writes) are very different things and should be treated separately.
Event sourcing (ES) goes beyond the use of domain events as a tool to model business logic. ES takes events to the next level by persisting them. In an ES scenario, your data source just consists of persisted events. You don’t likely have a classic relational data store; all you store are events, and you store them sequentially as they occur in the domain.