CQRS & Event SourcingAn alternative architecture for DDDDennis Doomen
The default architectureA better architectureThe alternative architectureAdvanced topics Contents
The Default ArchitectureEasy to buildAccepted by managementWell knownLots of resourcesLots of frameworksSilverlight ApplicationNo concurrencyScalability limitedNo domain verbsGranularity DTOsUnneccesary DTO conversionsConflicting demandsProxyDTOsServicesDomain ServicesDomain ModelRepositoriesUnit of WorkService AgentsRelationalDatabaseBackoffice Systems
CQRSSilverlight ApplicationCommands are verbsNo DTO conversionEasy to build disconnected clientsQuery Store = No SQLVery scalableService AgentQueriesBusiness ActionsDTOsCommandsCommand ServiceQuery ServiceCommand HandlersDomain ServicesDomain ModelData Access LayerRepositoriesUoWService AgentsDifficult to sync databaseNo concurrencyRequires a task-based UIComplexityRelationalDatabaseQuery StoreBackoffice SystemsChangesQuery Store
Task-based UIs a.k.a. Inductive UIs answer:What am I supposed to do now?Where do I go from here to accomplish my task?Task-based UIs
Focus screens on single taskMake the task’s intention clearOffer links to secondary tasksProvide screens for starting tasksMake the next step obviousFrom Microsoft Inductive User Interface GuidelinesGuidelines for Task-based UIs
Are valid or not, regardless of contextNamed in Ubiquitous LanguageState intentCan be asynchronous......but beware of eventual consistencyRejection via exception or fault eventCommands
One table per UI viewExposed through SOA-style web servicesWCF data servicesWCF RIA ServicesCan be anythingRelational DatabaseNo SQL databaseXML filesQuery Store
CQRS & Event SourcingSilverlight ApplicationGreat performanceConflict MergingHistorical TrackingTrival SynchronizationEasy IntegrationIndependent Query Store QueriesService AgentBusiness ActionsCommandsDTOsCommand ServiceCommand HandlersDomain ServicesDomain ModelEventsQuery ServiceDenormalizerEventsEvent HandlersLots of new conceptsNot so acceptableFew resourcesNo consensus yetMore complexityAggregate boundaries importantData Access LayerUoWEvent BusDomain RepositoryService AgentsQuery StoreEvent StoreQuery StoreBackoffice SystemsEvents
Represent state changes in aggregate rootNamed in passed tenseUsing Ubiquitous LanguageEntire aggregate is stored in serialized formatEvents never changeSnapshots to improve performanceEvents
Have no relationships (!)Communicate through eventsEntities do not expose setters (!)Apply events to themselvesState exposed as mementosAggregate Roots
Conflict Merging
Event Schema Versioning- Adds missing properties- Renames renamed properties- Converts valuesPost ConverterProperty Bag ConverterPost ConverterPost Converterid = 123SQL ServerDomain RepositoryEvent StorePropertyBagGet(id = 123)Eventid = 123
Event Store != relational database...so no unique constraintsWorkaroundsCheck uniqueness through query sideAdd generic unique column to event storeIntroduce a parent that enforces uniquenessUnique Constraints
The CQRS KitchenViews (XAML + C#)View ModelsApplication ServicesUnityService AgentCommandsDTOsCommand ServiceCommand HandlersWCFDomain ServicesMementosDomain ModelUnityEnterprise Library 5NCQRS++NSerivceBusEventsEvent HandlersEvent BusDomain RepositoryEventsUoWEvent StoreQuery ServiceDenormalizersWCF Data ServicesThin Data Access LayerEntity Framework 4SQL ServerEntity Framework 4SQL Server
NCQRSThe CQRS framework for .NET http://ncqrs.codeplex.com/Very promisingGreat DocumentationQuality codeUses Code ContractsVery active teamI’m considering joining (Still) difficult to get startedNot proven yetNot complete yetFeels a bit too complexNot everything is pluggableMisses a coding standard
In summaryGreat for performanceVery scalableSupports historical auditingSupports high concurrencyEasy to integrate with other systemsVery testable with TDD/DDDAligns great with Ubiquitous LanguageDoesn’t require expensive RDBMSLots of new conceptsLots of choices to makeNot yet accepted by managementLimited documentationNo consensus yetMore complexityAggregate design is importantI haven’t found all issues yet
Background InformationGreg Young, Mark Nijhof, Udi Dahan, Jonathan OliverExample Code, FrameworksThe CQRS Kitchen, NCQRSInteraction Design / Task-Based UIsThe Inmates Are Running The Asylum, Alan CooperMicrosoft Inductive User Interface GuidelinesLinks
Emaildennis.doomen@avivasolutions.nlTwitterddoomenBlogwww.dennisdoomen.netQuestions?

More Related Content

PPSX
Event Sourcing & CQRS, Kafka, Rabbit MQ
PPSX
Domain Driven Design
PPTX
Introduction to microservices
PPTX
Introduction to Microservices
PPTX
Introduction to Apache Camel
PDF
Best Practices for Streaming IoT Data with MQTT and Apache Kafka®
PDF
Microservice Architecture
PPTX
Microservices Part 3 Service Mesh and Kafka
Event Sourcing & CQRS, Kafka, Rabbit MQ
Domain Driven Design
Introduction to microservices
Introduction to Microservices
Introduction to Apache Camel
Best Practices for Streaming IoT Data with MQTT and Apache Kafka®
Microservice Architecture
Microservices Part 3 Service Mesh and Kafka

What's hot (20)

PDF
Microservices architecture
PDF
Building Event Driven (Micro)services with Apache Kafka
PPTX
Domain Driven Design
PDF
Implementing Domain Events with Kafka
PPTX
Microservices in the Apache Kafka Ecosystem
PDF
Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...
PDF
Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...
PDF
Microservices for Application Modernisation
PPSX
Rest api standards and best practices
PPTX
Domain Driven Design
PDF
Messaging in CQRS with MassTransit
PDF
Understanding MicroSERVICE Architecture with Java & Spring Boot
PPTX
Microservices Architecture - Bangkok 2018
PPSX
Apache Flink, AWS Kinesis, Analytics
PDF
Microservices with Java, Spring Boot and Spring Cloud
PPSX
Microservices Docker Kubernetes Istio Kanban DevOps SRE
PDF
Real-Life Use Cases & Architectures for Event Streaming with Apache Kafka
PDF
Fundamentals of Apache Kafka
PDF
Service discovery with Eureka and Spring Cloud
PPTX
Kafka 101
Microservices architecture
Building Event Driven (Micro)services with Apache Kafka
Domain Driven Design
Implementing Domain Events with Kafka
Microservices in the Apache Kafka Ecosystem
Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...
Pyspark Tutorial | Introduction to Apache Spark with Python | PySpark Trainin...
Microservices for Application Modernisation
Rest api standards and best practices
Domain Driven Design
Messaging in CQRS with MassTransit
Understanding MicroSERVICE Architecture with Java & Spring Boot
Microservices Architecture - Bangkok 2018
Apache Flink, AWS Kinesis, Analytics
Microservices with Java, Spring Boot and Spring Cloud
Microservices Docker Kubernetes Istio Kanban DevOps SRE
Real-Life Use Cases & Architectures for Event Streaming with Apache Kafka
Fundamentals of Apache Kafka
Service discovery with Eureka and Spring Cloud
Kafka 101
Ad

Viewers also liked (9)

PDF
CQRS and Event Sourcing with Akka, Cassandra and RabbitMQ
PDF
A year with event sourcing and CQRS
PDF
CQRS & event sourcing in the wild
PDF
From ActiveRecord to EventSourcing
PDF
CQRS & Event Sourcing in the wild (ScotlandPHP 2016)
PDF
Microservice Architecture with CQRS and Event Sourcing
PDF
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
PDF
CQRS and Event Sourcing for Java Developers
PDF
codecentric AG: CQRS and Event Sourcing Applications with Cassandra
CQRS and Event Sourcing with Akka, Cassandra and RabbitMQ
A year with event sourcing and CQRS
CQRS & event sourcing in the wild
From ActiveRecord to EventSourcing
CQRS & Event Sourcing in the wild (ScotlandPHP 2016)
Microservice Architecture with CQRS and Event Sourcing
Developing event-driven microservices with event sourcing and CQRS (svcc, sv...
CQRS and Event Sourcing for Java Developers
codecentric AG: CQRS and Event Sourcing Applications with Cassandra
Ad

Similar to CQRS and Event Sourcing, An Alternative Architecture for DDD (20)

PPT
Windows Azure for .NET Developers
PPTX
Roles y Responsabilidades en SQL Azure
PPTX
Cqrs and event sourcing in azure
PPTX
Silverlight 4 Reference Architecture for LOB apps
PPTX
Architectural Refactoring
PDF
Shaping serverless architecture with domain driven design patterns
PDF
Shaping serverless architecture with domain driven design patterns
PPT
Day Of Cloud - Windows Azure Platform
PPT
Introduction To Sql Services
PPTX
Crafted Design - LJC World Tour Mash Up 2014
PPTX
Sql Azure Pass
PPTX
Sql Azure Pass
PPTX
Introducing SQL Server Data Services
PPTX
Introducing SQL Server Data Services
PPTX
Dennis Doomen. Using OWIN, Webhooks, Event Sourcing and the Onion Architectur...
PPTX
SQL Azure the database in the cloud
PPTX
Microsoft SQL Azure - Building Applications Using SQL Azure Presentation
PPTX
Chalk and Talk: Silverlight, WCF RIA Services, Architectuur
PPTX
The web as it should be
PPTX
Windows Azure
Windows Azure for .NET Developers
Roles y Responsabilidades en SQL Azure
Cqrs and event sourcing in azure
Silverlight 4 Reference Architecture for LOB apps
Architectural Refactoring
Shaping serverless architecture with domain driven design patterns
Shaping serverless architecture with domain driven design patterns
Day Of Cloud - Windows Azure Platform
Introduction To Sql Services
Crafted Design - LJC World Tour Mash Up 2014
Sql Azure Pass
Sql Azure Pass
Introducing SQL Server Data Services
Introducing SQL Server Data Services
Dennis Doomen. Using OWIN, Webhooks, Event Sourcing and the Onion Architectur...
SQL Azure the database in the cloud
Microsoft SQL Azure - Building Applications Using SQL Azure Presentation
Chalk and Talk: Silverlight, WCF RIA Services, Architectuur
The web as it should be
Windows Azure

More from Dennis Doomen (20)

PDF
15 Years of Insights from a TDD Practitioner (NDC Oslo)
PPTX
Using Boundary-Driven Development to beat code complexity
PPTX
Getting a grip on your code dependencies (2023-10)
PPTX
Tools and practices to help you deal with legacy code
PPTX
What you can learn from an open-source project with 250 million downloads
PPTX
Getting a grip on your code dependencies
PPTX
My Laws of Test Driven Development (2023)
PPTX
Design patterns for Event Sourcing in .NET
PPTX
Automate Infrastructure with Pulumi and C#
PPTX
What is the right unit in unit testing (UpdateConf 2022)
PPTX
Slow Event Sourcing (re)projections - Just make them faster!
PPTX
50 things software teams should not do.pptx
PPTX
What is the right "unit" in unit testing and why it is not a class?
PPTX
A lab around the principles and practices for writing maintainable code
PPTX
How to Practice TDD Without Shooting Yourself in the Foot
PPTX
Decomposing the Monolith using modern-day .NET and a touch of microservices
PPTX
Event Sourcing from the Trenches (DDD Europe 2020)
PPTX
Practical introduction to DDD, CQRS and Event Sourcing
PPTX
How to practice TDD without shooting yourself in the foot
PPTX
Decomposing the Monolith (Riga Dev Days 2019)
15 Years of Insights from a TDD Practitioner (NDC Oslo)
Using Boundary-Driven Development to beat code complexity
Getting a grip on your code dependencies (2023-10)
Tools and practices to help you deal with legacy code
What you can learn from an open-source project with 250 million downloads
Getting a grip on your code dependencies
My Laws of Test Driven Development (2023)
Design patterns for Event Sourcing in .NET
Automate Infrastructure with Pulumi and C#
What is the right unit in unit testing (UpdateConf 2022)
Slow Event Sourcing (re)projections - Just make them faster!
50 things software teams should not do.pptx
What is the right "unit" in unit testing and why it is not a class?
A lab around the principles and practices for writing maintainable code
How to Practice TDD Without Shooting Yourself in the Foot
Decomposing the Monolith using modern-day .NET and a touch of microservices
Event Sourcing from the Trenches (DDD Europe 2020)
Practical introduction to DDD, CQRS and Event Sourcing
How to practice TDD without shooting yourself in the foot
Decomposing the Monolith (Riga Dev Days 2019)

Recently uploaded (20)

PDF
Transform-Quality-Engineering-with-AI-A-60-Day-Blueprint-for-Digital-Success.pdf
PPTX
SGT Report The Beast Plan and Cyberphysical Systems of Control
PPTX
Presentation - Principles of Instructional Design.pptx
PDF
NewMind AI Weekly Chronicles – August ’25 Week IV
PDF
Planning-an-Audit-A-How-To-Guide-Checklist-WP.pdf
PDF
Auditboard EB SOX Playbook 2023 edition.
PDF
giants, standing on the shoulders of - by Daniel Stenberg
PDF
Lung cancer patients survival prediction using outlier detection and optimize...
PDF
Transform-Your-Factory-with-AI-Driven-Quality-Engineering.pdf
PDF
The-Future-of-Automotive-Quality-is-Here-AI-Driven-Engineering.pdf
PDF
4 layer Arch & Reference Arch of IoT.pdf
PDF
EIS-Webinar-Regulated-Industries-2025-08.pdf
PDF
LMS bot: enhanced learning management systems for improved student learning e...
PDF
IT-ITes Industry bjjbnkmkhkhknbmhkhmjhjkhj
PDF
Aug23rd - Mulesoft Community Workshop - Hyd, India.pdf
PPTX
Internet of Everything -Basic concepts details
PDF
“The Future of Visual AI: Efficient Multimodal Intelligence,” a Keynote Prese...
PDF
Examining Bias in AI Generated News Content.pdf
PDF
Introduction to MCP and A2A Protocols: Enabling Agent Communication
PDF
Dell Pro Micro: Speed customer interactions, patient processing, and learning...
Transform-Quality-Engineering-with-AI-A-60-Day-Blueprint-for-Digital-Success.pdf
SGT Report The Beast Plan and Cyberphysical Systems of Control
Presentation - Principles of Instructional Design.pptx
NewMind AI Weekly Chronicles – August ’25 Week IV
Planning-an-Audit-A-How-To-Guide-Checklist-WP.pdf
Auditboard EB SOX Playbook 2023 edition.
giants, standing on the shoulders of - by Daniel Stenberg
Lung cancer patients survival prediction using outlier detection and optimize...
Transform-Your-Factory-with-AI-Driven-Quality-Engineering.pdf
The-Future-of-Automotive-Quality-is-Here-AI-Driven-Engineering.pdf
4 layer Arch & Reference Arch of IoT.pdf
EIS-Webinar-Regulated-Industries-2025-08.pdf
LMS bot: enhanced learning management systems for improved student learning e...
IT-ITes Industry bjjbnkmkhkhknbmhkhmjhjkhj
Aug23rd - Mulesoft Community Workshop - Hyd, India.pdf
Internet of Everything -Basic concepts details
“The Future of Visual AI: Efficient Multimodal Intelligence,” a Keynote Prese...
Examining Bias in AI Generated News Content.pdf
Introduction to MCP and A2A Protocols: Enabling Agent Communication
Dell Pro Micro: Speed customer interactions, patient processing, and learning...

CQRS and Event Sourcing, An Alternative Architecture for DDD

  • 1. CQRS & Event SourcingAn alternative architecture for DDDDennis Doomen
  • 2. The default architectureA better architectureThe alternative architectureAdvanced topics Contents
  • 3. The Default ArchitectureEasy to buildAccepted by managementWell knownLots of resourcesLots of frameworksSilverlight ApplicationNo concurrencyScalability limitedNo domain verbsGranularity DTOsUnneccesary DTO conversionsConflicting demandsProxyDTOsServicesDomain ServicesDomain ModelRepositoriesUnit of WorkService AgentsRelationalDatabaseBackoffice Systems
  • 4. CQRSSilverlight ApplicationCommands are verbsNo DTO conversionEasy to build disconnected clientsQuery Store = No SQLVery scalableService AgentQueriesBusiness ActionsDTOsCommandsCommand ServiceQuery ServiceCommand HandlersDomain ServicesDomain ModelData Access LayerRepositoriesUoWService AgentsDifficult to sync databaseNo concurrencyRequires a task-based UIComplexityRelationalDatabaseQuery StoreBackoffice SystemsChangesQuery Store
  • 5. Task-based UIs a.k.a. Inductive UIs answer:What am I supposed to do now?Where do I go from here to accomplish my task?Task-based UIs
  • 6. Focus screens on single taskMake the task’s intention clearOffer links to secondary tasksProvide screens for starting tasksMake the next step obviousFrom Microsoft Inductive User Interface GuidelinesGuidelines for Task-based UIs
  • 7. Are valid or not, regardless of contextNamed in Ubiquitous LanguageState intentCan be asynchronous......but beware of eventual consistencyRejection via exception or fault eventCommands
  • 8. One table per UI viewExposed through SOA-style web servicesWCF data servicesWCF RIA ServicesCan be anythingRelational DatabaseNo SQL databaseXML filesQuery Store
  • 9. CQRS & Event SourcingSilverlight ApplicationGreat performanceConflict MergingHistorical TrackingTrival SynchronizationEasy IntegrationIndependent Query Store QueriesService AgentBusiness ActionsCommandsDTOsCommand ServiceCommand HandlersDomain ServicesDomain ModelEventsQuery ServiceDenormalizerEventsEvent HandlersLots of new conceptsNot so acceptableFew resourcesNo consensus yetMore complexityAggregate boundaries importantData Access LayerUoWEvent BusDomain RepositoryService AgentsQuery StoreEvent StoreQuery StoreBackoffice SystemsEvents
  • 10. Represent state changes in aggregate rootNamed in passed tenseUsing Ubiquitous LanguageEntire aggregate is stored in serialized formatEvents never changeSnapshots to improve performanceEvents
  • 11. Have no relationships (!)Communicate through eventsEntities do not expose setters (!)Apply events to themselvesState exposed as mementosAggregate Roots
  • 13. Event Schema Versioning- Adds missing properties- Renames renamed properties- Converts valuesPost ConverterProperty Bag ConverterPost ConverterPost Converterid = 123SQL ServerDomain RepositoryEvent StorePropertyBagGet(id = 123)Eventid = 123
  • 14. Event Store != relational database...so no unique constraintsWorkaroundsCheck uniqueness through query sideAdd generic unique column to event storeIntroduce a parent that enforces uniquenessUnique Constraints
  • 15. The CQRS KitchenViews (XAML + C#)View ModelsApplication ServicesUnityService AgentCommandsDTOsCommand ServiceCommand HandlersWCFDomain ServicesMementosDomain ModelUnityEnterprise Library 5NCQRS++NSerivceBusEventsEvent HandlersEvent BusDomain RepositoryEventsUoWEvent StoreQuery ServiceDenormalizersWCF Data ServicesThin Data Access LayerEntity Framework 4SQL ServerEntity Framework 4SQL Server
  • 16. NCQRSThe CQRS framework for .NET http://ncqrs.codeplex.com/Very promisingGreat DocumentationQuality codeUses Code ContractsVery active teamI’m considering joining (Still) difficult to get startedNot proven yetNot complete yetFeels a bit too complexNot everything is pluggableMisses a coding standard
  • 17. In summaryGreat for performanceVery scalableSupports historical auditingSupports high concurrencyEasy to integrate with other systemsVery testable with TDD/DDDAligns great with Ubiquitous LanguageDoesn’t require expensive RDBMSLots of new conceptsLots of choices to makeNot yet accepted by managementLimited documentationNo consensus yetMore complexityAggregate design is importantI haven’t found all issues yet
  • 18. Background InformationGreg Young, Mark Nijhof, Udi Dahan, Jonathan OliverExample Code, FrameworksThe CQRS Kitchen, NCQRSInteraction Design / Task-Based UIsThe Inmates Are Running The Asylum, Alan CooperMicrosoft Inductive User Interface GuidelinesLinks

Editor's Notes

  • #4: DisadvantagesNo concurrency; conflicting service requests are simply rejectedStaleness ignored;Scalability limited; No domain verbs; domain model does contain concepts from the domain model, just not the business actionsGranularity DTOs; What operations to expose in your WCF service? What relations to include and when? What domain entities to flatten.Unneccesary DTO conversions; Conversions from/to domain model entities, traversing of relations, eager fatchingConflicting demands; query demands denormalized schema, commands require normalized integer schema
  • #5: DisadvantagesNo concurrency; conflicting service requests are simply rejectedStaleness ignored;Scalability limited; No domain verbs; domain model does contain concepts from the domain model, just not the business actionsGranularity DTOs; What operations to expose in your WCF service? What relations to include and when? What domain entities to flatten.Unneccesary DTO conversions; Conversions from/to domain model entities, traversing of relations, eager fatchingConflicting demands; query demands denormalized schema, commands require normalized integer schema
  • #8: Commands validate itself without using any context, thus is valid or not instead of sometimes.Commands are named in the Ubiquitous LanguageCommands can be send asynchronously, and thus can be resistent to database unavailabilityMogelijk meerdere commands met dezeflde state change: CorrectCustomerAddress, MoveCustomerCommand interfaces: in-memory, WCF, WCF RIA Services, NServiceBus, etc
  • #10: DisadvantagesNo concurrency; conflicting service requests are simply rejectedStaleness ignored;Scalability limited; No domain verbs; domain model does contain concepts from the domain model, just not the business actionsGranularity DTOs; What operations to expose in your WCF service? What relations to include and when? What domain entities to flatten.Unneccesary DTO conversions; Conversions from/to domain model entities, traversing of relations, eager fatchingConflicting demands; query demands denormalized schema, commands require normalized integer schema
  • #16: DisadvantagesNo concurrency; conflicting service requests are simply rejectedStaleness ignored;Scalability limited; No domain verbs; domain model does contain concepts from the domain model, just not the business actionsGranularity DTOs; What operations to expose in your WCF service? What relations to include and when? What domain entities to flatten.Unneccesary DTO conversions; Conversions from/to domain model entities, traversing of relations, eager fatchingConflicting demands; query demands denormalized schema, commands require normalized integer schema