Skip to content

CQRS Concepts

Duncan Jones edited this page Dec 16, 2018 · 2 revisions

CQRS is the separation of the command side of an application (being anything which alters the state of the system) from the query side of the system (being anything that retrieves the state).

In this system (based on Azure Event Grid and Durable Functions ) both commands and queries are triggered by sending an event grid event to the appropriate command or query handler.

Each Entity in the system (i.e. anything which can be uniquely identifiable and which can have a state) is backed by its own unique event stream. Commands are implemented by writing events to the end of the event stream for that entity. These are implemented on top of AppendBlobs, with each event being stored as a JSON formatted block.

Event stream of an entity

To get the data out of these event streams a projection is run over them. This is a simple piece of code that takes each event in turn and decides (1) do I care about this event type and (2) if so, what do I do when I encounter it. The values of the projection when it has run over an entire event stream represent a view of the state of the entity backed by that event stream.

Projection

Clone this wiki locally