From the course: Software Architecture: Patterns for Developers (2020)

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

CQRS and event sourcing combined

CQRS and event sourcing combined

- [Narrator] The term CQRS and event sourcing are often used interchangeably. Even though one can be implemented without the other, the combination can be very powerful. Let's see how the combination would look like. We'll start with an event sourced application. Our entities are built by replaying events on a new object. That's how we restart a state of an object. When we want to alter the state, we add a new event and handle that event. When we persist the events, we can trigger our event handlers to perform actions on other objects or systems. To add CQRS to the mix, we want to separate our read model from our right model. In our event sourced application, the whole system of events and handlers is our right model. To add a read model, all we need to do is make event handlers that populate the read model. Then we can add the necessary code to query this read model. Combining CQRS and event sourcing gives you…

Contents