Dino Esposito on CQRS, Messages and Events

| by Jan Stenberg Follow 34 Followers on Aug 31, 2015. Estimated reading time: 2 minutes |

Command Query Responsibility Segregation (CQRS) is the starting point of a change that will have a profound impact on system architecture, Dino Esposito claims in three articles in MSDN Magazine. It’s the first step in a longer evolution transitioning software architects from the idea of “models-to-persist” to the idea of “events-to-log”. He envisions that the next few years will primarily be about architecture, with event-based data as the primary data source instead of data snapshots.

Esposito, a Microsoft MVP since 2006, describes CQRS as a design style separating code that alters state from code that reads state. He emphasizes that simply recognizing that commands and queries are two different things may have an impact on software architecture, making it simpler to envision and code each part. The command side can focus on business rules while the query side’s only concern is returning data. The respective pipeline can also be optimized without risk of breaking the other one. The most basic form of CQRS separates writes and reads but uses one database. There are more advanced forms though, a subject Vladimir Khorikov wrote about earlier.

Esposito notes that many developers tend to apply CQRS only to collaborative and high-scale applications, but to him it’s an approach to software development that has benefits regardless of the perceived complexity of a system. Although CQRS excels in applications with a high degree of business complexity he thinks it’s a simple and powerful pattern also right for common, e.g. CRUD based, applications.

For Esposito the major benefit of a message-based architecture is that it simplifies managing complex and changing business workflows to support new scenarios. He notes that building a message-based system without using CQRS is very hard, if not impossible. By adding domain events workflows can be modelled in terms of individual actions, (triggered by commands), and events. Creating handlers taking care of commands and subsequent events the workflow is broken down into many small steps thereby simplifying changes of the workflow.

One aspect of a CRUD system that Esposito has found often goes unnoticed is that data stored is a snapshot; it’s the last known system state. With a request for a feature requiring the application clock to be moved backward, storing just snapshots can never fulfil that request. The only solution he sees in this scenario is to re-architect the system to save domain events, storing all changes in the domain. Storing data as events decreases the data abstraction level, giving the opportunity to use the same data for different purposes, including plain queries, business intelligence and usage analytics.

Rate this Article

Adoption Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

A fourth article by Esposito by Jan Stenberg

Esposito has written a fourth article, about Event Sourcing

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

1 Discuss

Login to InfoQ to interact with what matters most to you.

Recover your password...


Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.


More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.


Stay up-to-date

Set up your notifications and don't miss out on content that matters to you