CQRS and Event Sourcing are popular architectural patterns that allow you to build effective event-driven micro-services.
The basic idea of these patterns is to record each event that changes the state of the domain model into the event-storage.
This approach allows you to reduce service latency for any data scale, as well as be able to restore the system without losing any data.
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
CQRS and Event Sourcing
1. CQRS and Event Sourcing in
.NET
.NET Excellence Center at Intellias
Sergiy Seletsky
Senior Solutions Architect
MEETUP
2. .NET Excellence Center – what is it?
Community development
Presales support
Consulting
Interview support and preparation
Mentorship
Employee Assessment
And more…
Intellias CoEs is a virtual organization of proactive people, who go beyond their regular
duties and employ their expertise where this is crucial for the company to succeed.
Join our team of proactive experts if you are senior+, of course ;)
For details contact: Tetiana Kulbatska
3. Agenda
Pain points of traditional architecture
CQS and CQRS theory
Event Sourcing in .NET
DDD and Event-driven microservices
Reference implementation for .NET
Q&A
4. • Scalability of System is by larger and larger
RDBMS
• Surprise, surprise!
• Persistence means ‘save the Current State’ of
the domain model
• Query concerns are at odds with Transactional
concerns
• System audit adds extra complexity
• Issues with complex data schema versioning
• more…
Application Design Pain Points
5. Domain
Modeling Pain
Points Business Rules only exist in user’s
heads
Converting Domain Objects to DTOs
(and back again!)
Domain Object Persistence
Lazy vs. Eager Fetching
Optimizing Domain for efficient
Queries
Setter/Getter Anti-Pattern
Tests are (often) brittle
more…
6. Business Pain
Points
Must know what business questions
we want to ask up front
Optimizing for Queries and
Optimizing for Transactions are tied
together (and very expensive)
Evolving Requirements is
hard/expensive
more…
8. Command-Query Separation
• Command-Query Separation (CQS) states that 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.
• More formally, methods should return a value only if they are
referentially transparent and hence possess no side effects.
Query - returns data and not apply any changes
Command - apply changes and not returns data, only result of
execution
12. Command-Query
Responsibility Segregation
• The CQS principles applied to your
domain modeling and system architecture
• Enable each element of your architecture
to be optimized for a single responsibility
• Decomposition for your architecture rather
than just for your objects
23. Event Sourcing advantages
Events are immutable and can be stored using an append-only
operation.
Events are simple objects that describe some action that occurred
Events typically have meaning for a domain expert
Event sourcing can help prevent concurrent updates from causing
conflicts because it avoids the requirement to directly update objects in
the data store
The append-only storage of events provides an audit trail that can be
used to monitor actions taken against a data store
The event store raises events, and tasks perform operations in
response to those events.
39. Resources
Greg Young - Building an Event Storage
Microsoft - Exploring CQRS and Event Sourcing
Greg Young - CQRS & Event Sourcing
Lorenzo Nicora - A visual introduction to event sourcing and cqrs
Greg Young - A Decade of DDD, CQRS, Event Sourcing
Martin Fowler - Event Sourcing
Eric Evans - DDD and Microservices: At Last, Some Boudaries!
Martin Kleppmann — Event Sourcing and Stream Processing at Scale
Julie Lerman - Data Points - CQRS and EF Data Models
Vaughn Vernon - Reactive DDD: Modeling Uncertainty
Mark Seemann - CQS versus server generated IDs
Udi Dahan - If (domain logic) then CQRS, or Saga?
Event Store - The open-source, functional database with Complex Event Processing in JavaScript
Pedro Costa - Migrating to Microservices and Event-Sourcing: the Dos and Dont’s
David Boike - Putting your events on a diet
DDD Quickly
Dennis Doomen - The Good, The Bad and the Ugly of Event Sourcing
Liquid Projections - A set of highly efficient building blocks to build fast autonomous synchronous and asynchronous projector