Chapter 8. CQRS and Event Sourcing
This chapter covers
- The basics of Command Query Responsibility Segregation
- CQRS in reactive systems
- Commands and queries
- CQRS and Event Sourcing combined
As you’ve seen in the previous chapters, the reactive paradigm is a powerful way to think about distributed computing. In this chapter, we build on that foundation by exploring two design patterns introduced in chapter 1: Command Query Responsibility Segregation (CQRS) and Event Sourcing (ES). We should note, however, that although these techniques work in concert and are a natural fit for reactive programming, they’re by no means the only way to design a reactive system.
To achieve our goal of exploring these two design patterns, we look at a common type of application: the database-driven application, which is the foundation of many, if not most, systems built today. We explore the challenges in building these types of applications in a distributed environment and show you how, through the reactive paradigm, you can use CQRS/ES to overcome these challenges.