SlideShare a Scribd company logo
1 of 45
Download to read offline
ES, CQRS & DDD: Lessons Learned (and walls bumped into)
Gitte Vermeiren | @GitteTitter
One does not simply
Use ES, CQRS & DDD
UI
Commands
Command Bus
Command
Command Handler
Domain
Model
Domain
Model
Domain
Model
Repository
Event Store
Aggregates
Events
Event Handler
Data
Thin Data Layer
Query DTO
Event Bus
Events
Person
Dossier
Payment
TechnicalInvestigation
DocumentGroup
Task
TaskClosedEvent
TaskPerformedEvent
DocumentRenamedEvent
TaskCreatedEvent
DocumentJudgedEvent
DocumentAddedToDocumentGroupEvent
DocumentMovedEvent
DossierApprovedForPaymentEvent
DocumentPrintedEvent
https://github.com/MarkNijhof/Fohjin
Problem 1
“Every ‘dossier’, ‘scan’, ‘decision’, ... Should
have a unique incremental number”
UI
Commands
Command Bus
Command
Command Handler
Domain
Model
Domain
Model
Domain
Model
Repository
Event Store
Aggregates
Events
Event Handler
Data
Thin Data Layer
Query DTO
Event Bus
Events
Use an
autoincrement
column?
Use a
‘DossierNumberGenerator’
DossierNumberGenerator
_highestNumber = 0
1. GenerateNext
2. DossierNumberGeneratedEvent
3. onDossierNumberGenerated
_highestNumber ++;
DossierNumberGenerator
_highestNumber = 0
onDossierNumberGenerated
_highestNumber ++;
DossierNumberGeneratedEvent
DossierNumberGeneratedEvent
DossierNumberGeneratedEvent
Replay
Repository.GetById<DossierNumberGenerator>(id);
UI
Commands
Command Bus
Command
Command Handler
Domain
Model
Domain
Model
Domain
Model
Repository
Event Store
Aggregates
Events
Event Handler
Data
Thin Data Layer
Query DTO
Event Bus
Events
Use a domain
service
Problem 2
DomainEvent
Id
AggregateId
Version
Raised
repo.GetById<Aggregate>(aggregateId);
Get/Store events based on
type, not on
eventproviderId?
Migrate those events
WIP
AnotherNewRefactoredAggregate
ANewRefactoredAggregate
anAggregate
SomeEvent
SomeOtherEvent
AndSomeMoreEvent
Migration
Process
SomeEvent
SomeOtherEvent
AndSomeMoreEvent
AndAFunkyEvent
https://github.com/vermegi/Eventstream.Migratorhttps://github.com/NEventStore/NEventStore.Migrations
Event Store
Event Store
Read the entire event stream Save the entire event stream
UI
Commands
Command Bus
Command
Command Handler
Domain
Model
Domain
Model
Domain
Model
Repository
Event Store
Aggregates
Events
Event Handler
Data
Thin Data Layer
Query DTO
Event Bus
Events
Replay needed
Event Versioning with an
EventUpdater
AnAggregate
_somePrivateStuff = 0
onSomeEvent:
_somePriveStuff = somevalue;
SomeEvent
AnotherEvent
AndAnotherEvent
Replay
Repository.GetById<AnAggregate>(aggregateId);
SomeEvent
AnotherEvent
AndAnotherEvent
Update
Repository.GetById<AnAggregate>(aggregateId);
SomeUpdatedEvent
AnotherEvent
AndAnotherEvent
AndAnotherEvent
Problem 3
AnAggregateSnapshot
Repository.GetById<AnAggregate>(aggregateId);
_version = 666
SomeEvent
Version = 667
AnotherEvent
Version = 668
AndAnotherEvent
Version = 669
AnAggregate
_somePrivateStuff = 0
onSomeEvent:
_somePriveStuff = somevalue;
Replay
Problem 4
Hard to use in debugging
Hard to do data updates
Hard to query
Problem 5
AnAggregate
_somePrivateValue = 0
DoSomething
onSomethingHappened
_somePrivateValue = something;
DoSomething
SomethingHappenedEvent
UI
Commands
Command Bus
Command
Command Handler
Domain
Model
Domain
Model
Domain
Model
Repository
Event Store
Aggregates
Events
Event Handler
Data
Thin Data Layer
Query DTO
Event Bus
Events
Hard to do data
updates
Reuse the same
logic
Do it functional
Problem 6
And for the good news?
Some final thoughts ...
VISUG Partners

More Related Content

What's hot

Cloud connected cross platform apps in visual studio
Cloud connected cross platform apps in visual studioCloud connected cross platform apps in visual studio
Cloud connected cross platform apps in visual studio
James Montemagno
 
[Td 2015]general session 세상을 품은 플랫폼과 그 가능성에 대하여(기술에반젤리스트)
[Td 2015]general session 세상을 품은 플랫폼과 그 가능성에 대하여(기술에반젤리스트)[Td 2015]general session 세상을 품은 플랫폼과 그 가능성에 대하여(기술에반젤리스트)
[Td 2015]general session 세상을 품은 플랫폼과 그 가능성에 대하여(기술에반젤리스트)
Sang Don Kim
 

What's hot (16)

Launch It With Docker
Launch It With DockerLaunch It With Docker
Launch It With Docker
 
.NET Everywhere and for Everyone
.NET Everywhere and for Everyone.NET Everywhere and for Everyone
.NET Everywhere and for Everyone
 
.NET Conf 2019 高雄場 - .NET Core 3.0
.NET Conf 2019 高雄場 - .NET Core 3.0.NET Conf 2019 高雄場 - .NET Core 3.0
.NET Conf 2019 高雄場 - .NET Core 3.0
 
"The F# Path to Relaxation", Don Syme
"The F# Path to Relaxation", Don Syme"The F# Path to Relaxation", Don Syme
"The F# Path to Relaxation", Don Syme
 
ASP.NET Core deployment options
ASP.NET Core deployment optionsASP.NET Core deployment options
ASP.NET Core deployment options
 
Building a mobile application for dot netnuke
Building a mobile application for dot netnukeBuilding a mobile application for dot netnuke
Building a mobile application for dot netnuke
 
Iteratively Develop Microservices with Speed on Kubernetes
Iteratively Develop Microservices with Speed on KubernetesIteratively Develop Microservices with Speed on Kubernetes
Iteratively Develop Microservices with Speed on Kubernetes
 
Jeffrey Richter
Jeffrey RichterJeffrey Richter
Jeffrey Richter
 
Forms + azure
Forms + azureForms + azure
Forms + azure
 
SLUGUK BUILD Round-up
SLUGUK BUILD Round-upSLUGUK BUILD Round-up
SLUGUK BUILD Round-up
 
Build 2017 - Whats new for Xamarin Devs
Build 2017 - Whats new for Xamarin DevsBuild 2017 - Whats new for Xamarin Devs
Build 2017 - Whats new for Xamarin Devs
 
Dev days 1 Introduction to Xamarin Taswar Bhatti
Dev days 1 Introduction to Xamarin Taswar BhattiDev days 1 Introduction to Xamarin Taswar Bhatti
Dev days 1 Introduction to Xamarin Taswar Bhatti
 
Cloud Native Jenkins Deployment in Azure
Cloud Native Jenkins Deployment in AzureCloud Native Jenkins Deployment in Azure
Cloud Native Jenkins Deployment in Azure
 
Cloud connected cross platform apps in visual studio
Cloud connected cross platform apps in visual studioCloud connected cross platform apps in visual studio
Cloud connected cross platform apps in visual studio
 
Yet Another Chatter Desktop
Yet Another Chatter DesktopYet Another Chatter Desktop
Yet Another Chatter Desktop
 
[Td 2015]general session 세상을 품은 플랫폼과 그 가능성에 대하여(기술에반젤리스트)
[Td 2015]general session 세상을 품은 플랫폼과 그 가능성에 대하여(기술에반젤리스트)[Td 2015]general session 세상을 품은 플랫폼과 그 가능성에 대하여(기술에반젤리스트)
[Td 2015]general session 세상을 품은 플랫폼과 그 가능성에 대하여(기술에반젤리스트)
 

Viewers also liked

A year with event sourcing and CQRS
A year with event sourcing and CQRSA year with event sourcing and CQRS
A year with event sourcing and CQRS
Steve Pember
 

Viewers also liked (9)

SciSmalltalk: Doing Science with Agility
SciSmalltalk: Doing Science with AgilitySciSmalltalk: Doing Science with Agility
SciSmalltalk: Doing Science with Agility
 
L07 Oranizing Domain Logic
L07 Oranizing Domain LogicL07 Oranizing Domain Logic
L07 Oranizing Domain Logic
 
CQRS and Event Sourcing
CQRS and Event SourcingCQRS and Event Sourcing
CQRS and Event Sourcing
 
CQRS recipes or how to cook your architecture
CQRS recipes or how to cook your architectureCQRS recipes or how to cook your architecture
CQRS recipes or how to cook your architecture
 
A year with event sourcing and CQRS
A year with event sourcing and CQRSA year with event sourcing and CQRS
A year with event sourcing and CQRS
 
From APM to Business Monitoring with AppDynamics Analytics
From APM to Business Monitoring with AppDynamics AnalyticsFrom APM to Business Monitoring with AppDynamics Analytics
From APM to Business Monitoring with AppDynamics Analytics
 
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
 
CQRS and Event Sourcing, An Alternative Architecture for DDD
CQRS and Event Sourcing, An Alternative Architecture for DDDCQRS and Event Sourcing, An Alternative Architecture for DDD
CQRS and Event Sourcing, An Alternative Architecture for DDD
 
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...
 

Similar to DDD, CQRS & ES lessons learned (Gitte Vermeiren)

Introduction To Dojo
Introduction To DojoIntroduction To Dojo
Introduction To Dojo
yoavrubin
 
Event Sourcing with Kotlin, who needs frameworks!
Event Sourcing with Kotlin, who needs frameworks!Event Sourcing with Kotlin, who needs frameworks!
Event Sourcing with Kotlin, who needs frameworks!
Nico Krijnen
 

Similar to DDD, CQRS & ES lessons learned (Gitte Vermeiren) (20)

DDD, CQRS, ES lessons learned
DDD, CQRS, ES lessons learnedDDD, CQRS, ES lessons learned
DDD, CQRS, ES lessons learned
 
Decomposing the Monolith using modern-day .NET and a touch of microservices
Decomposing the Monolith using modern-day .NET and a touch of microservicesDecomposing the Monolith using modern-day .NET and a touch of microservices
Decomposing the Monolith using modern-day .NET and a touch of microservices
 
Cqrs and event sourcing in azure
Cqrs and event sourcing in azureCqrs and event sourcing in azure
Cqrs and event sourcing in azure
 
A framework for self-healing applications – the path to enable auto-remediation
A framework for self-healing applications – the path to enable auto-remediationA framework for self-healing applications – the path to enable auto-remediation
A framework for self-healing applications – the path to enable auto-remediation
 
DDD meets CQRS and event sourcing
DDD meets CQRS and event sourcingDDD meets CQRS and event sourcing
DDD meets CQRS and event sourcing
 
CQRS / ES & DDD Demystified
CQRS / ES & DDD DemystifiedCQRS / ES & DDD Demystified
CQRS / ES & DDD Demystified
 
Evernote Touch App Artifact Report
Evernote Touch App Artifact Report Evernote Touch App Artifact Report
Evernote Touch App Artifact Report
 
MongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDBMongoDB.local Atlanta: Introduction to Serverless MongoDB
MongoDB.local Atlanta: Introduction to Serverless MongoDB
 
Meetup Performance
Meetup PerformanceMeetup Performance
Meetup Performance
 
Meetup Performance
Meetup PerformanceMeetup Performance
Meetup Performance
 
Introduction To Dojo
Introduction To DojoIntroduction To Dojo
Introduction To Dojo
 
Complex event flows in distributed systems (QCon London 2019)
Complex event flows in distributed systems (QCon London 2019)Complex event flows in distributed systems (QCon London 2019)
Complex event flows in distributed systems (QCon London 2019)
 
2006 - Basta!: Advanced server controls
2006 - Basta!: Advanced server controls2006 - Basta!: Advanced server controls
2006 - Basta!: Advanced server controls
 
Complex Event Processing with Esper
Complex Event Processing with EsperComplex Event Processing with Esper
Complex Event Processing with Esper
 
Develop in ludicrous mode with azure serverless
Develop in ludicrous mode with azure serverlessDevelop in ludicrous mode with azure serverless
Develop in ludicrous mode with azure serverless
 
Event Sourcing from the Trenches (with examples from .NET)
Event Sourcing from the Trenches (with examples from .NET)Event Sourcing from the Trenches (with examples from .NET)
Event Sourcing from the Trenches (with examples from .NET)
 
The Fine Art of Time Travelling: implementing Event Sourcing
The Fine Art of Time Travelling: implementing Event SourcingThe Fine Art of Time Travelling: implementing Event Sourcing
The Fine Art of Time Travelling: implementing Event Sourcing
 
Scaling django
Scaling djangoScaling django
Scaling django
 
Android is not just mobile
Android is not just mobileAndroid is not just mobile
Android is not just mobile
 
Event Sourcing with Kotlin, who needs frameworks!
Event Sourcing with Kotlin, who needs frameworks!Event Sourcing with Kotlin, who needs frameworks!
Event Sourcing with Kotlin, who needs frameworks!
 

More from Visug

Visug: Say Hello to my little friend: a session on Kinect
Visug: Say Hello to my little friend: a session on KinectVisug: Say Hello to my little friend: a session on Kinect
Visug: Say Hello to my little friend: a session on Kinect
Visug
 

More from Visug (12)

Gdbc keynote-visug
Gdbc keynote-visugGdbc keynote-visug
Gdbc keynote-visug
 
Making enabling apps for disabled people
Making enabling apps for disabled peopleMaking enabling apps for disabled people
Making enabling apps for disabled people
 
How many iot technologies do you need to turn on a lightbulb (Kurt Claeys)
How many iot technologies do you need to turn on a lightbulb (Kurt Claeys)How many iot technologies do you need to turn on a lightbulb (Kurt Claeys)
How many iot technologies do you need to turn on a lightbulb (Kurt Claeys)
 
Tfs Build vNext (Jelle Druyts)
Tfs Build vNext (Jelle Druyts)Tfs Build vNext (Jelle Druyts)
Tfs Build vNext (Jelle Druyts)
 
Sherlock Homepage (Maarten Balliauw)
Sherlock Homepage (Maarten Balliauw)Sherlock Homepage (Maarten Balliauw)
Sherlock Homepage (Maarten Balliauw)
 
DevOps with Visual studio Release Management (Pieter Gheysens)
DevOps with Visual studio Release Management (Pieter Gheysens)DevOps with Visual studio Release Management (Pieter Gheysens)
DevOps with Visual studio Release Management (Pieter Gheysens)
 
Asp.net core 1.0 (Peter Himschoot)
Asp.net core 1.0 (Peter Himschoot)Asp.net core 1.0 (Peter Himschoot)
Asp.net core 1.0 (Peter Himschoot)
 
Exploring XLabs
Exploring XLabsExploring XLabs
Exploring XLabs
 
Hello windows 10: An overview of the new features for developers in WIndows 10
Hello windows 10: An overview of the new features for developers in WIndows 10Hello windows 10: An overview of the new features for developers in WIndows 10
Hello windows 10: An overview of the new features for developers in WIndows 10
 
Embracing HTTP in the era of API’s
Embracing HTTP in the era of API’sEmbracing HTTP in the era of API’s
Embracing HTTP in the era of API’s
 
So you write JavaScript? Keep the crap out of there then!
So you write JavaScript? Keep the crap out of there then!So you write JavaScript? Keep the crap out of there then!
So you write JavaScript? Keep the crap out of there then!
 
Visug: Say Hello to my little friend: a session on Kinect
Visug: Say Hello to my little friend: a session on KinectVisug: Say Hello to my little friend: a session on Kinect
Visug: Say Hello to my little friend: a session on Kinect
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 

DDD, CQRS & ES lessons learned (Gitte Vermeiren)