Features
Quick changes
Maintainability
Cost
Performance
CQRS & ES, it really is a ES & CQRS.
You can use CQRS without ES, but with ES you must use CQRS.
by Greg Young
Consistency of data is a state which is eventually attained
...what leads us to CAP theorem
...a distributed system cannot satisfy all three of these guarantees at the same time...
Eric Brewer
we don't have network partitions (P)
... so it is CA system
we have network partitions (P)
... so it can be only CP or AP system
Amazon ;)
Tickets buying system
ATM application ;)
... but let's back to
Something that has had already happened
Represents state change
Should be named in past tense
... and in business language (Ubiquitous Language)
They never change!
... unless you have a time machine
... or you play Orwell and rewrite history
term coined by Greg Young (@gregyoung)
also Udi Dahan (@udidahan) involved
based on CQS devised by Bertrand Meyer
Bertrand defines CQS as: every method should either be a command that performs an action, or a query that returns data to the caller, but not both. In other words, asking a question should not change the answer.
Named in business language (Ubiquitous Language)
Express user's intention
Simple validations (regardless of context)
Rejection by exception or fault event
Can be asynchronous
a.k.a Form Object
Handle commands :)
Entry point to your domain
Handle all plumbing
Cross cutting concerns as Chain Of Responsibility
Triggered by users, external systems or sagas (process managers)
a.k.a Service Object (some of them)
Something that has had already happened
Represents state change
Should be named in past tense
... and in business language (Ubiquitous Language)
They never change!
... unless you have a time machine
... or you play Orwell and rewrite history
A place where (almost) all yours app logic should be
Set of objects holding consistent/valid state
Protecting invariants
... more in DDD books :)
State rebuild based on events
Source of new events
Do not expose state
The model as your app needs it
Denormalized!
Tailor-made!
Recreatable!
Could be anything: relational DB, NoSQL store, graph database
... static HTML file ;)
a.k.a Query Objects (in half baked CQRS implementation with shared database)
blogs:
books, docs & articles:
samples:
communities:
https://talks.praglowski.com/cqrs-es/