SlideShare a Scribd company logo
1 of 16
Download to read offline
Implementing
Event Sourcing in .NET
Andrea Saltarello
CEO @ managed/designs
andysal@gmail.com
http://twitter.com/andysal74
http://slideshare.net/andysal
Who I am
1. CEO @ Managed Designs, striving to discover the perfect
«sustainable software development process»
• Customer has to be satisfied and pay
• Supplier has to have a reasonable markup
• Team members should be satisfied with their work
2. Founder and leader of UGIdotNET (first Italian .NET User
Group): I need to share experiences in a peer to peer way
3. (Co)Author (together with Dino) of .NET: Architecting
Applications for the Enterprise, by Microsoft Press
4. Basically, a software developer 
CQRS recap
Query Command
DEMO
CQRS recap
It really became clear to me in the last couple of years
that we need a new building block and that is the
Domain Event.
[Eric Evans]
An event is something that has happened in the past.
[Greg Young]
A domain event … captures the memory of something
interesting which affects the domain
[Martin Fowler]
Why events?
«Undo principle»: Instead of focusing on a system’s last
known state, we could note down every occurring
event: this way, we would be able build the state the
system was in at any point in time
To cut a long story short: we end up recording an event
stream
JobOrderCreated InvoiceIssuedJobOrderExtended JobOrderClosed
Event Stream vs. «My application»
Still, my users are more interested in knowing a
job order’s balance or whether an invoice has
been paid.
Ways to achieve that:
• Rebuilding the state traversing the whole
event stream (slow, but snapshots can help)
• CQRS to the rescue: let’s have a database
dedicated to store the last known state and
have it read by the read model
CQRS/ES in a nutshell
1. Application sends a command to the system
2. Command execution alters the system’s state and
raises events to state success/failure
3. Events are notified to interested subscribers, such
as:
• Workflow managers (a.k.a. «Sagas») which can
execute more commands
• Denormalizers, which will update the read
model
Note: command/event dispatch will usually be
managed by a Mediator («bus»)
Read
Model
Application
Layer
Domain
layer
Event
store
QUERY
COMMAND
Bus
EVENT Handler
Handler
Handler
Snapshot
DB
CQRS/ES at a glance
DEMO
Merp
On a technology side…
Looking for a bus and an event store: build or buy?
• Event Store:
–SQLWhatever
–MongoDB
–RavenDB
• Bus:
–NEventStore
–NServiceBus
My advice? Buy
#donoteverthinkaboutmakingyourowntoolkit
The “Buy” Side of the Force
SQLWhatever MongoDB RavenDB
• Everyone’s skill
• Every tool you can
need does exist
• Both On-Premise
& cloud
• Free
• Runs on both
Linux and
Windows
• Both On-Premise
& cloud
• Schemaless
• LINQ support
• TX+DTC support
• Schemaless
• Both On-Premise
& cloud
MSMQ NEventStore NServiceBus
• ROTFL • Free
• FOSS
• DDD/CQRS/ES full
stack
• Advances config
options
• Advanced
notifications
features
DEMO
NServiceBus
Bibliography
[DDD] Domain Driven Design, Eric Evans , Addison-Wesley
What I've learned about DDD since the book, Eric Evans, InfoQ
[NAAE] Microsoft .NET: Architecting Applications for the
Enterprise (2° ed.), Andrea Saltarello & Dino Esposito,
Microsoft Press
[MERP] Merp, https://naa4e.codeplex.com/
Implementing Event Sourcing in .NET

More Related Content

What's hot

What's hot (13)

Backbone And Marionette : Take Over The World
Backbone And Marionette : Take Over The WorldBackbone And Marionette : Take Over The World
Backbone And Marionette : Take Over The World
 
Meteor meetup
Meteor meetupMeteor meetup
Meteor meetup
 
Containerisation and orchestration of mautic application
Containerisation and orchestration of mautic applicationContainerisation and orchestration of mautic application
Containerisation and orchestration of mautic application
 
Arsitektur Aplikasi Modern - Faisal Henry Susanto
Arsitektur Aplikasi Modern - Faisal Henry SusantoArsitektur Aplikasi Modern - Faisal Henry Susanto
Arsitektur Aplikasi Modern - Faisal Henry Susanto
 
TechTalk - Building Serverless Applications with IBM Bluemix
TechTalk - Building Serverless Applications with IBM BluemixTechTalk - Building Serverless Applications with IBM Bluemix
TechTalk - Building Serverless Applications with IBM Bluemix
 
KDE Plasma Mobile workspaces at Cybercom Developer Day 2010 by Marco Martin 7...
KDE Plasma Mobile workspaces at Cybercom Developer Day 2010 by Marco Martin 7...KDE Plasma Mobile workspaces at Cybercom Developer Day 2010 by Marco Martin 7...
KDE Plasma Mobile workspaces at Cybercom Developer Day 2010 by Marco Martin 7...
 
TechTalk Webinar Series - Getting Started with Apache OpenWhisk
TechTalk Webinar Series - Getting Started with Apache OpenWhiskTechTalk Webinar Series - Getting Started with Apache OpenWhisk
TechTalk Webinar Series - Getting Started with Apache OpenWhisk
 
ReactJs
ReactJsReactJs
ReactJs
 
What is new in ASP.NET Core
What is new in ASP.NET CoreWhat is new in ASP.NET Core
What is new in ASP.NET Core
 
A quick tour around Azure Dev Spaces
A quick tour around Azure Dev SpacesA quick tour around Azure Dev Spaces
A quick tour around Azure Dev Spaces
 
Xamarin devdays 2017 - PT - connected apps
Xamarin devdays 2017 - PT - connected appsXamarin devdays 2017 - PT - connected apps
Xamarin devdays 2017 - PT - connected apps
 
Azure kubernetes service (aks)
Azure kubernetes service (aks)Azure kubernetes service (aks)
Azure kubernetes service (aks)
 
Ext js 6
Ext js 6Ext js 6
Ext js 6
 

Viewers also liked

How I did it (in .NET): idiomatic Domain Driven Design
How I did it (in .NET): idiomatic Domain Driven DesignHow I did it (in .NET): idiomatic Domain Driven Design
How I did it (in .NET): idiomatic Domain Driven Design
Andrea Saltarello
 
Inventory system
Inventory systemInventory system
Inventory system
sai prakash
 

Viewers also liked (13)

Da Rotor a .NET Core ed indietro: Microsoft <3 Open Source
Da Rotor a .NET Core ed indietro: Microsoft <3 Open SourceDa Rotor a .NET Core ed indietro: Microsoft <3 Open Source
Da Rotor a .NET Core ed indietro: Microsoft <3 Open Source
 
Never Mind the Bollocks: here's the Domain Driven Design
Never Mind the Bollocks: here's the Domain Driven DesignNever Mind the Bollocks: here's the Domain Driven Design
Never Mind the Bollocks: here's the Domain Driven Design
 
ASP.NET Core essentials
ASP.NET Core essentialsASP.NET Core essentials
ASP.NET Core essentials
 
How I did it (in .NET): idiomatic Domain Driven Design
How I did it (in .NET): idiomatic Domain Driven DesignHow I did it (in .NET): idiomatic Domain Driven Design
How I did it (in .NET): idiomatic Domain Driven Design
 
Destiny Online Catalog System
Destiny Online Catalog SystemDestiny Online Catalog System
Destiny Online Catalog System
 
Domain Event - The Hidden Gem of DDD
Domain Event - The Hidden Gem of DDDDomain Event - The Hidden Gem of DDD
Domain Event - The Hidden Gem of DDD
 
Developing event-driven microservices with event sourcing and CQRS (phillyete)
Developing event-driven microservices with event sourcing and CQRS (phillyete)Developing event-driven microservices with event sourcing and CQRS (phillyete)
Developing event-driven microservices with event sourcing and CQRS (phillyete)
 
Developing functional domain models with event sourcing (sbtb, sbtb2015)
Developing functional domain models with event sourcing (sbtb, sbtb2015)Developing functional domain models with event sourcing (sbtb, sbtb2015)
Developing functional domain models with event sourcing (sbtb, sbtb2015)
 
Design of a Computerized Inventory Management System for Supermarkets
Design of a Computerized Inventory Management System for SupermarketsDesign of a Computerized Inventory Management System for Supermarkets
Design of a Computerized Inventory Management System for Supermarkets
 
Microservice Architecture with CQRS and Event Sourcing
Microservice Architecture with CQRS and Event SourcingMicroservice Architecture with CQRS and Event Sourcing
Microservice Architecture with CQRS and Event Sourcing
 
Unique ID generation in distributed systems
Unique ID generation in distributed systemsUnique ID generation in distributed systems
Unique ID generation in distributed systems
 
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
Developing event-driven microservices with event sourcing and CQRS  (svcc, sv...Developing event-driven microservices with event sourcing and CQRS  (svcc, sv...
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
 
Inventory system
Inventory systemInventory system
Inventory system
 

Similar to Implementing Event Sourcing in .NET

Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...
Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...
Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...
confluent
 
PLATEAU 2011 - Capturing and Analyzing Low-Level Events from the Code Editor
PLATEAU 2011 - Capturing and Analyzing Low-Level Events from the Code EditorPLATEAU 2011 - Capturing and Analyzing Low-Level Events from the Code Editor
PLATEAU 2011 - Capturing and Analyzing Low-Level Events from the Code Editor
YoungSeok Yoon
 

Similar to Implementing Event Sourcing in .NET (20)

Azure tales: a real world CQRS and ES Deep Dive - Andrea Saltarello
Azure tales: a real world CQRS and ES Deep Dive - Andrea SaltarelloAzure tales: a real world CQRS and ES Deep Dive - Andrea Saltarello
Azure tales: a real world CQRS and ES Deep Dive - Andrea Saltarello
 
Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...
Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...
Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...
 
2017 Melbourne YOW! CTO Summit - Monolith to micro-services with CQRS & Event...
2017 Melbourne YOW! CTO Summit - Monolith to micro-services with CQRS & Event...2017 Melbourne YOW! CTO Summit - Monolith to micro-services with CQRS & Event...
2017 Melbourne YOW! CTO Summit - Monolith to micro-services with CQRS & Event...
 
The Fine Art of Time Travelling - Implementing Event Sourcing - Andrea Saltar...
The Fine Art of Time Travelling - Implementing Event Sourcing - Andrea Saltar...The Fine Art of Time Travelling - Implementing Event Sourcing - Andrea Saltar...
The Fine Art of Time Travelling - Implementing Event Sourcing - Andrea Saltar...
 
OOSE UNIT-1.pdf
OOSE UNIT-1.pdfOOSE UNIT-1.pdf
OOSE UNIT-1.pdf
 
Advance Microservice Patterns - Event Souring , CQRS
Advance Microservice Patterns - Event Souring , CQRSAdvance Microservice Patterns - Event Souring , CQRS
Advance Microservice Patterns - Event Souring , CQRS
 
Our way to microservices
Our way to microservicesOur way to microservices
Our way to microservices
 
Stateful patterns in Azure Functions
Stateful patterns in Azure FunctionsStateful patterns in Azure Functions
Stateful patterns in Azure Functions
 
Thinking Outside the Cube: How In-Memory Bolsters Analytics
Thinking Outside the Cube: How In-Memory Bolsters AnalyticsThinking Outside the Cube: How In-Memory Bolsters Analytics
Thinking Outside the Cube: How In-Memory Bolsters Analytics
 
Microservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native AppsMicroservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native Apps
 
Advanced web application architecture - Talk
Advanced web application architecture - TalkAdvanced web application architecture - Talk
Advanced web application architecture - Talk
 
Code instrumentation
Code instrumentationCode instrumentation
Code instrumentation
 
E-BOOK MANAGEMENT SYSTEM PowerPoint Presentation
E-BOOK MANAGEMENT SYSTEM  PowerPoint PresentationE-BOOK MANAGEMENT SYSTEM  PowerPoint Presentation
E-BOOK MANAGEMENT SYSTEM PowerPoint Presentation
 
Responding to extended events in near real time
Responding to extended events in near real timeResponding to extended events in near real time
Responding to extended events in near real time
 
Event sourcing and CQRS: Lessons from the trenches
Event sourcing and CQRS: Lessons from the trenchesEvent sourcing and CQRS: Lessons from the trenches
Event sourcing and CQRS: Lessons from the trenches
 
How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...
How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...
How to build streaming data pipelines with Akka Streams, Flink, and Spark usi...
 
PLATEAU 2011 - Capturing and Analyzing Low-Level Events from the Code Editor
PLATEAU 2011 - Capturing and Analyzing Low-Level Events from the Code EditorPLATEAU 2011 - Capturing and Analyzing Low-Level Events from the Code Editor
PLATEAU 2011 - Capturing and Analyzing Low-Level Events from the Code Editor
 
University of Gujrat Lahore sub Campus Documentation FYP
University of Gujrat Lahore sub Campus Documentation FYPUniversity of Gujrat Lahore sub Campus Documentation FYP
University of Gujrat Lahore sub Campus Documentation FYP
 
Part 1: DRS and DPM Implementation in Virtualized Environment, Part 2: Large ...
Part 1: DRS and DPM Implementation in Virtualized Environment, Part 2: Large ...Part 1: DRS and DPM Implementation in Virtualized Environment, Part 2: Large ...
Part 1: DRS and DPM Implementation in Virtualized Environment, Part 2: Large ...
 
GECon2017_Building scalable application with cqrs and event sourcing (a. hars...
GECon2017_Building scalable application with cqrs and event sourcing (a. hars...GECon2017_Building scalable application with cqrs and event sourcing (a. hars...
GECon2017_Building scalable application with cqrs and event sourcing (a. hars...
 

More from Andrea Saltarello

Idiomatic Domain Driven Design
Idiomatic Domain Driven DesignIdiomatic Domain Driven Design
Idiomatic Domain Driven Design
Andrea Saltarello
 
From relational data to object spaces
From relational data to object spacesFrom relational data to object spaces
From relational data to object spaces
Andrea Saltarello
 

More from Andrea Saltarello (8)

Layered Expression Trees feat. CQRS
Layered Expression Trees feat. CQRSLayered Expression Trees feat. CQRS
Layered Expression Trees feat. CQRS
 
ASP.NET MVC: Full Throttle
ASP.NET MVC: Full ThrottleASP.NET MVC: Full Throttle
ASP.NET MVC: Full Throttle
 
Code Contracts and Generics: implementing a LINQ-enabled Repository
Code Contracts and Generics: implementing a LINQ-enabled RepositoryCode Contracts and Generics: implementing a LINQ-enabled Repository
Code Contracts and Generics: implementing a LINQ-enabled Repository
 
Idiomatic Domain Driven Design
Idiomatic Domain Driven DesignIdiomatic Domain Driven Design
Idiomatic Domain Driven Design
 
Build a LINQ-enabled Repository
Build a LINQ-enabled RepositoryBuild a LINQ-enabled Repository
Build a LINQ-enabled Repository
 
Layered Expression Trees: una terza via (idiomatica) verso il DDD
Layered Expression Trees: una terza via (idiomatica) verso il DDDLayered Expression Trees: una terza via (idiomatica) verso il DDD
Layered Expression Trees: una terza via (idiomatica) verso il DDD
 
From relational data to object spaces
From relational data to object spacesFrom relational data to object spaces
From relational data to object spaces
 
MVC2: non solo tecnologia
MVC2: non solo tecnologiaMVC2: non solo tecnologia
MVC2: non solo tecnologia
 

Recently uploaded

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Recently uploaded (20)

%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 

Implementing Event Sourcing in .NET

  • 1.
  • 2. Implementing Event Sourcing in .NET Andrea Saltarello CEO @ managed/designs andysal@gmail.com http://twitter.com/andysal74 http://slideshare.net/andysal
  • 3. Who I am 1. CEO @ Managed Designs, striving to discover the perfect «sustainable software development process» • Customer has to be satisfied and pay • Supplier has to have a reasonable markup • Team members should be satisfied with their work 2. Founder and leader of UGIdotNET (first Italian .NET User Group): I need to share experiences in a peer to peer way 3. (Co)Author (together with Dino) of .NET: Architecting Applications for the Enterprise, by Microsoft Press 4. Basically, a software developer 
  • 6. It really became clear to me in the last couple of years that we need a new building block and that is the Domain Event. [Eric Evans] An event is something that has happened in the past. [Greg Young] A domain event … captures the memory of something interesting which affects the domain [Martin Fowler]
  • 7. Why events? «Undo principle»: Instead of focusing on a system’s last known state, we could note down every occurring event: this way, we would be able build the state the system was in at any point in time To cut a long story short: we end up recording an event stream JobOrderCreated InvoiceIssuedJobOrderExtended JobOrderClosed
  • 8. Event Stream vs. «My application» Still, my users are more interested in knowing a job order’s balance or whether an invoice has been paid. Ways to achieve that: • Rebuilding the state traversing the whole event stream (slow, but snapshots can help) • CQRS to the rescue: let’s have a database dedicated to store the last known state and have it read by the read model
  • 9. CQRS/ES in a nutshell 1. Application sends a command to the system 2. Command execution alters the system’s state and raises events to state success/failure 3. Events are notified to interested subscribers, such as: • Workflow managers (a.k.a. «Sagas») which can execute more commands • Denormalizers, which will update the read model Note: command/event dispatch will usually be managed by a Mediator («bus»)
  • 12. On a technology side… Looking for a bus and an event store: build or buy? • Event Store: –SQLWhatever –MongoDB –RavenDB • Bus: –NEventStore –NServiceBus My advice? Buy #donoteverthinkaboutmakingyourowntoolkit
  • 13. The “Buy” Side of the Force SQLWhatever MongoDB RavenDB • Everyone’s skill • Every tool you can need does exist • Both On-Premise & cloud • Free • Runs on both Linux and Windows • Both On-Premise & cloud • Schemaless • LINQ support • TX+DTC support • Schemaless • Both On-Premise & cloud MSMQ NEventStore NServiceBus • ROTFL • Free • FOSS • DDD/CQRS/ES full stack • Advances config options • Advanced notifications features
  • 15. Bibliography [DDD] Domain Driven Design, Eric Evans , Addison-Wesley What I've learned about DDD since the book, Eric Evans, InfoQ [NAAE] Microsoft .NET: Architecting Applications for the Enterprise (2° ed.), Andrea Saltarello & Dino Esposito, Microsoft Press [MERP] Merp, https://naa4e.codeplex.com/