Rethink your architecture with CQRS

Pieter Joost van de Sande
Pieter Joost van de SandeSoftware Developer at Happy Pancake
Change the Rules



Rethink you architecture with
           CQRS
Change the Rules




Who are those guys?

INTRODUCTION
Change the Rules
Change the Rules
Change the Rules


                  Agenda
•   Introduction
•   Current architectures & problems
•   CQRS
•   Food for thought
Change the Rules
Change the Rules


Huidige architecturen




      bron: .NET Application Architecture Guide 2.0
Change the Rules


Huidige architecturen
       Presentation layer




       Application layer




           Data layer
Change the Rules


multi-tier
 Presentation layer




   Domain layer




     Data layer
Change the Rules

                                                 Update DTO

                                           Presentation layer
                                      Request
                                        DTO




                          Map DTO

                                                Domain layer
        Request                       Request
          DTO                           DTO



       Map DTO                       Map DTO

                                                 Data layer
Query data   Query data       Query data   Query data
Change the Rules

                                                 Update DTO

                                           Presentation layer
                                      Request
                                                               Send DTO
                                        DTO




                          Map DTO                                               Map DTO

                                                Domain layer
        Request                       Request                    Send                             Send
          DTO                           DTO                      DTO                              DTO



       Map DTO                       Map DTO                     Map DTO                     Map DTO

                                                 Data layer
Query data   Query data       Query data   Query data    Write data     Write data   Write data      Write data
Change the Rules




“A single model cannot be appropriate for
reporting, searching, and transactional
behaviors.” – Greg Young
Change the Rules




“Doordat software processen kan
automatiseren stelt het ons in staat deze
verder op te schalen dan ooit tevoren.“
Change the Rules




“Every method should either be a
command that performs an action, or a
query that returns data to the caller, but
not both.” – Bertrand Meyer
Change the Rules




Presentation layer




  Domain layer




    Data layer
Change the Rules




             Presentation layer




Data layer                        Domain layer
Change the Rules




             Presentation layer




Data layer                        Domain layer
Change the Rules




                          Presentation layer




Read focus                                            State transition focus



             Data layer                        Domain layer
Change the Rules




                               Presentation layer



                          Queries            Commands
Read focus                                                     State transition focus



             Data layer                                 Domain layer
Change the Rules




                               Presentation layer



                          Queries            Commands
Read focus                                                     State transities focus



             Read layer                                 Domain layer
Change the Rules




Here we go!

FROM CONCEPT TO ARCHITECTUUR
Change the Rules




User interface
Change the Rules


                     Queries
•   Requests information
•   Is context dependant
•   Is executed many times
•   Should be simple (select * from x where y)

• Examples:
    – Get all products for user X
    – Get total price of all orders of month May
Change the Rules


                     Read side




User interface
Change the Rules


                         Read side




                 Read databases




User interface
Change the Rules


                         Read side




                 Read databases




                     Facade




User interface
Change the Rules


                          Read side




                 Read databases




                     Facade




                  DTO’s
User interface
Change the Rules


                 Read side
•   Focus on data needs
•   Optimized for reading
•   Can contain multiple models if needed
•   Can be denormalized
•   Facades should be minimized
Change the Rules




“State transitions are an important part of
our problem space and should be modeled
within our domain.” – Greg Young
Change the Rules


                 Commands
• Causes a state transition
• Contains the intend of the user
• Exists in a bounded context

• Examples:
  –   AddProductToShoppingCart
  –   PurchaseOrder
  –   MoveUserToNewAddress
  –   CorrectAddressForUser
Change the Rules


         Commands example



Create                                    Remove
         Add item   Add item   Add item            Purchase
 Cart                                      item
Change the Rules


Write side                                                Read side




                                                 Read databases




                                                     Facade



             Commandhandlers

                     commands                     DTO’s
                                User interface
Change the Rules


Command handler sample
Change the Rules


              The domain
• Validates and handles commands
• Encapsulates behavior
• Build with rich object oriented techniques
Change the Rules


Write side                                                      Read side




                                                       Read databases
                      Repository
             Domein




                                                           Facade



               Commandhandlers

                           commands                     DTO’s
                                      User interface
Change the Rules


Write side                                                          Read side




                                      ?
                                                           Read databases
                      Repository
             Domein




                                                               Facade



               Commandhandlers

                           commands                         DTO’s
                                          User interface
Change the Rules


             Domain events
• Result of a command
• Represents a event

• Examples
  – ProductAddedToShoppingCart
  – OrderPurchased
  – UserMovedToNewAddress
  – AddressCorrectedForUser
Change the Rules


Transitional flow
Change the Rules


Write side                                                          Read side




                                      ?
                                                           Read databases
                      Repository
             Domein




                                                               Facade



               Commandhandlers

                           commands                         DTO’s
                                          User interface
Change the Rules


Write side                                                                                             Read side




                                                                              Denormalizers
                                            Event bus
                                                        events       events




                                   events
                                                                                              Read databases
                      Repository
             Domein




                                                                                                  Facade



               Commandhandlers

                           commands                                                            DTO’s
                                                           User interface
Change the Rules


Denormalizer sample
Change the Rules


 Write side                                                                                                 Read side




                                                                                   Denormalizers
                                                 Event bus
                                                             events       events


                       events




                                        events
Event store
                                                                                                   Read databases
                           Repository
              Domein




                                                                                                       Facade



                Commandhandlers

                                commands                                                            DTO’s
                                                                User interface
Change the Rules


                 Event store
•   Contains all domain events
•   Does not need to be relational
•   Contains the audit log
•   Read models can (re)build themself of it
•   The domain uses it to get the current state
Change the Rules


 Write side                                                                                                     Read side




                                                                                       Denormalizers
                                                 Event bus
                                                             events           events


                       events




                                        events
                                                                      queue
Event store
                                                                                                       Read databases
                           Repository
              Domein




                                                                                                           Facade



                Commandhandlers

                                commands                                                                DTO’s
                                                                User interface
Change the Rules


Application flow
Change the Rules


            CQRS Wrapup
• The domain receives commands and
  publishes domain events.
• All state changes are represented by
domain Events
• The read models are updated as a result of
  the published Events
• All Queries go directly to the read models,
  the domain model is not involved
Change the Rules


                Benefits
• Fully encapsulated domain that only
  exposes behavior
Change the Rules


                Benefits
• Fully encapsulated domain that only
  exposes behavior
• Keep users intent
Change the Rules


                 Benefits
• Fully encapsulated domain that only
  exposes behavior
• Keep users intent
• Bullet-proof auditing and historical tracing
Change the Rules


                 Benefits
• Fully encapsulated domain that only
  exposes behavior
• Keep users intent
• Bullet-proof auditing and historical tracing
• No object-relational impedance mismatch
Change the Rules


                 Benefits
• Fully encapsulated domain that only
  exposes behavior
• Keep users intent
• Bullet-proof auditing and historical tracing
• No object-relational impedance mismatch
• Optimized and multiple read models
Change the Rules


                 Benefits
• Fully encapsulated domain that only
  exposes behavior
• Keep users intent
• Bullet-proof auditing and historical tracing
• No object-relational impedance mismatch
• Optimized and multiple read models
• Testability
Change the Rules


                 Benefits
• Fully encapsulated domain that only
  exposes behavior
• Keep users intent
• Bullet-proof auditing and historical tracing
• No object-relational impedance mismatch
• Optimized and multiple read models
• Testability
• Easy integration with external systems
Change the Rules


              Consequences
•   Learning curve
•   Overhead for simple CRUD
•   Data duplication
•   Introducing an new architecture has a big
    impact
Change the Rules


          Food for thought
• Should your read model even contains a
  relational database?
• What does this mean for requirement
  engineering?
• What does this mean for outsourcing?
• What does this mean for DBA?
Change the Rules


You’ve been a great audience!
Change the Rules


           Reference material
•   Podcast with Greg Young
•   MyShop reference architecture
•   Ncqrs framework
•   InfoQ: Unshackle Your Domain
1 of 57

Recommended

Going Serverless with CQRS on AWS by
Going Serverless with CQRS on AWSGoing Serverless with CQRS on AWS
Going Serverless with CQRS on AWSAnton Udovychenko
12.8K views64 slides
JUST EAT: Embracing DevOps by
JUST EAT: Embracing DevOpsJUST EAT: Embracing DevOps
JUST EAT: Embracing DevOpsPeter Mounce
5.4K views33 slides
AWS Summit London 2014 - JUST EAT - High Availability and Rapid Change by
AWS Summit London 2014 - JUST EAT - High Availability and Rapid ChangeAWS Summit London 2014 - JUST EAT - High Availability and Rapid Change
AWS Summit London 2014 - JUST EAT - High Availability and Rapid Changedaniel-richardson
8.9K views35 slides
Domain Driven Design 101 by
Domain Driven Design 101Domain Driven Design 101
Domain Driven Design 101Richard Dingwall
39.6K views55 slides
Unleash Your Domain With Greg Young @ DDD-Day by
Unleash Your Domain With Greg Young @ DDD-DayUnleash Your Domain With Greg Young @ DDD-Day
Unleash Your Domain With Greg Young @ DDD-DayDotNetMarche
2K views46 slides
Introduction to CQRS by
Introduction to CQRSIntroduction to CQRS
Introduction to CQRSPieter Joost van de Sande
1.7K views63 slides

More Related Content

Similar to Rethink your architecture with CQRS

Ibm data stage implementing etl solution using ibm datastage by
Ibm data stage  implementing etl solution using ibm datastageIbm data stage  implementing etl solution using ibm datastage
Ibm data stage implementing etl solution using ibm datastagebispsolutions
1K views2 slides
Datastage coursecontent by
Datastage coursecontentDatastage coursecontent
Datastage coursecontentAmit Sharma
312 views2 slides
Web 2.0 And The End Of DITA by
Web 2.0 And The End Of DITAWeb 2.0 And The End Of DITA
Web 2.0 And The End Of DITAJoe Gollner
702 views28 slides
OSS Presentation Keynote by Hal Stern by
OSS Presentation Keynote by Hal SternOSS Presentation Keynote by Hal Stern
OSS Presentation Keynote by Hal SternOpenStorageSummit
1.2K views29 slides
Linking Data and Actions on the Web by
Linking Data and Actions on the WebLinking Data and Actions on the Web
Linking Data and Actions on the WebStuart Charlton
1.4K views34 slides
Software-Defined Networking , Survey of HotSDN 2012 by
Software-Defined Networking , Survey of HotSDN 2012Software-Defined Networking , Survey of HotSDN 2012
Software-Defined Networking , Survey of HotSDN 2012Jason TC HOU (侯宗成)
2.8K views51 slides

Similar to Rethink your architecture with CQRS(20)

Ibm data stage implementing etl solution using ibm datastage by bispsolutions
Ibm data stage  implementing etl solution using ibm datastageIbm data stage  implementing etl solution using ibm datastage
Ibm data stage implementing etl solution using ibm datastage
bispsolutions1K views
Datastage coursecontent by Amit Sharma
Datastage coursecontentDatastage coursecontent
Datastage coursecontent
Amit Sharma312 views
Web 2.0 And The End Of DITA by Joe Gollner
Web 2.0 And The End Of DITAWeb 2.0 And The End Of DITA
Web 2.0 And The End Of DITA
Joe Gollner702 views
OSS Presentation Keynote by Hal Stern by OpenStorageSummit
OSS Presentation Keynote by Hal SternOSS Presentation Keynote by Hal Stern
OSS Presentation Keynote by Hal Stern
OpenStorageSummit1.2K views
Linking Data and Actions on the Web by Stuart Charlton
Linking Data and Actions on the WebLinking Data and Actions on the Web
Linking Data and Actions on the Web
Stuart Charlton1.4K views
All Aboard the Databus by Amy W. Tang
All Aboard the DatabusAll Aboard the Databus
All Aboard the Databus
Amy W. Tang2.4K views
DA_MAP by skbhate
DA_MAPDA_MAP
DA_MAP
skbhate352 views
Dennis Doomen. Using OWIN, Webhooks, Event Sourcing and the Onion Architectur... by IT Arena
Dennis Doomen. Using OWIN, Webhooks, Event Sourcing and the Onion Architectur...Dennis Doomen. Using OWIN, Webhooks, Event Sourcing and the Onion Architectur...
Dennis Doomen. Using OWIN, Webhooks, Event Sourcing and the Onion Architectur...
IT Arena297 views
Exploiting the Data / Code Duality with Dali by Carl Steinbach
Exploiting the Data / Code Duality with DaliExploiting the Data / Code Duality with Dali
Exploiting the Data / Code Duality with Dali
Carl Steinbach366 views
Standardizing the Data Distribution Service (DDS) API for Modern C++ by Sumant Tambe
Standardizing the Data Distribution Service (DDS) API for Modern C++Standardizing the Data Distribution Service (DDS) API for Modern C++
Standardizing the Data Distribution Service (DDS) API for Modern C++
Sumant Tambe8.8K views
Lap Around Sql Azure by Anko Duizer
Lap Around Sql AzureLap Around Sql Azure
Lap Around Sql Azure
Anko Duizer422 views
Summer Training In Dotnet by DUCC Systems
Summer Training In DotnetSummer Training In Dotnet
Summer Training In Dotnet
DUCC Systems3.3K views
CS 542 Parallel DBs, NoSQL, MapReduce by J Singh
CS 542 Parallel DBs, NoSQL, MapReduceCS 542 Parallel DBs, NoSQL, MapReduce
CS 542 Parallel DBs, NoSQL, MapReduce
J Singh1.8K views
Accelerating It Migration Success With A Rock Solid Hp And Red Hat Enterprise... by Vedanta Barooah
Accelerating It Migration Success With A Rock Solid Hp And Red Hat Enterprise...Accelerating It Migration Success With A Rock Solid Hp And Red Hat Enterprise...
Accelerating It Migration Success With A Rock Solid Hp And Red Hat Enterprise...
Vedanta Barooah1.1K views

More from Pieter Joost van de Sande

Actor Model by
Actor ModelActor Model
Actor ModelPieter Joost van de Sande
750 views104 slides
Microservices by
MicroservicesMicroservices
MicroservicesPieter Joost van de Sande
8.7K views65 slides
Microservices by
MicroservicesMicroservices
MicroservicesPieter Joost van de Sande
1.2K views62 slides
Werckers path to Go by
Werckers path to GoWerckers path to Go
Werckers path to GoPieter Joost van de Sande
595 views41 slides
Lessons for developers - long edition by
Lessons for developers  - long editionLessons for developers  - long edition
Lessons for developers - long editionPieter Joost van de Sande
728 views38 slides
Introduction to (n)CQRS by
Introduction to (n)CQRSIntroduction to (n)CQRS
Introduction to (n)CQRSPieter Joost van de Sande
314 views1 slide

Recently uploaded

Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica... by
Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica...Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica...
Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica...NUS-ISS
15 views28 slides
Combining Orchestration and Choreography for a Clean Architecture by
Combining Orchestration and Choreography for a Clean ArchitectureCombining Orchestration and Choreography for a Clean Architecture
Combining Orchestration and Choreography for a Clean ArchitectureThomasHeinrichs1
68 views24 slides
How the World's Leading Independent Automotive Distributor is Reinventing Its... by
How the World's Leading Independent Automotive Distributor is Reinventing Its...How the World's Leading Independent Automotive Distributor is Reinventing Its...
How the World's Leading Independent Automotive Distributor is Reinventing Its...NUS-ISS
15 views25 slides
The details of description: Techniques, tips, and tangents on alternative tex... by
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...BookNet Canada
110 views24 slides
20231123_Camunda Meetup Vienna.pdf by
20231123_Camunda Meetup Vienna.pdf20231123_Camunda Meetup Vienna.pdf
20231123_Camunda Meetup Vienna.pdfPhactum Softwareentwicklung GmbH
23 views73 slides

Recently uploaded(20)

Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica... by NUS-ISS
Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica...Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica...
Emerging & Future Technology - How to Prepare for the Next 10 Years of Radica...
NUS-ISS15 views
Combining Orchestration and Choreography for a Clean Architecture by ThomasHeinrichs1
Combining Orchestration and Choreography for a Clean ArchitectureCombining Orchestration and Choreography for a Clean Architecture
Combining Orchestration and Choreography for a Clean Architecture
ThomasHeinrichs168 views
How the World's Leading Independent Automotive Distributor is Reinventing Its... by NUS-ISS
How the World's Leading Independent Automotive Distributor is Reinventing Its...How the World's Leading Independent Automotive Distributor is Reinventing Its...
How the World's Leading Independent Automotive Distributor is Reinventing Its...
NUS-ISS15 views
The details of description: Techniques, tips, and tangents on alternative tex... by BookNet Canada
The details of description: Techniques, tips, and tangents on alternative tex...The details of description: Techniques, tips, and tangents on alternative tex...
The details of description: Techniques, tips, and tangents on alternative tex...
BookNet Canada110 views
AI: mind, matter, meaning, metaphors, being, becoming, life values by Twain Liu 刘秋艳
AI: mind, matter, meaning, metaphors, being, becoming, life valuesAI: mind, matter, meaning, metaphors, being, becoming, life values
AI: mind, matter, meaning, metaphors, being, becoming, life values
Future of Learning - Khoong Chan Meng by NUS-ISS
Future of Learning - Khoong Chan MengFuture of Learning - Khoong Chan Meng
Future of Learning - Khoong Chan Meng
NUS-ISS31 views
Transcript: The Details of Description Techniques tips and tangents on altern... by BookNet Canada
Transcript: The Details of Description Techniques tips and tangents on altern...Transcript: The Details of Description Techniques tips and tangents on altern...
Transcript: The Details of Description Techniques tips and tangents on altern...
BookNet Canada119 views
STPI OctaNE CoE Brochure.pdf by madhurjyapb
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdf
madhurjyapb12 views
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV by Splunk
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV
.conf Go 2023 - How KPN drives Customer Satisfaction on IPTV
Splunk86 views
Attacking IoT Devices from a Web Perspective - Linux Day by Simone Onofri
Attacking IoT Devices from a Web Perspective - Linux Day Attacking IoT Devices from a Web Perspective - Linux Day
Attacking IoT Devices from a Web Perspective - Linux Day
Simone Onofri15 views
Future of Learning - Yap Aye Wee.pdf by NUS-ISS
Future of Learning - Yap Aye Wee.pdfFuture of Learning - Yap Aye Wee.pdf
Future of Learning - Yap Aye Wee.pdf
NUS-ISS38 views
Perth MeetUp November 2023 by Michael Price
Perth MeetUp November 2023 Perth MeetUp November 2023
Perth MeetUp November 2023
Michael Price12 views
PharoJS - Zürich Smalltalk Group Meetup November 2023 by Noury Bouraqadi
PharoJS - Zürich Smalltalk Group Meetup November 2023PharoJS - Zürich Smalltalk Group Meetup November 2023
PharoJS - Zürich Smalltalk Group Meetup November 2023
Noury Bouraqadi113 views
.conf Go 2023 - Data analysis as a routine by Splunk
.conf Go 2023 - Data analysis as a routine.conf Go 2023 - Data analysis as a routine
.conf Go 2023 - Data analysis as a routine
Splunk90 views
Beyond the Hype: What Generative AI Means for the Future of Work - Damien Cum... by NUS-ISS
Beyond the Hype: What Generative AI Means for the Future of Work - Damien Cum...Beyond the Hype: What Generative AI Means for the Future of Work - Damien Cum...
Beyond the Hype: What Generative AI Means for the Future of Work - Damien Cum...
NUS-ISS28 views
Web Dev - 1 PPT.pdf by gdsczhcet
Web Dev - 1 PPT.pdfWeb Dev - 1 PPT.pdf
Web Dev - 1 PPT.pdf
gdsczhcet52 views

Rethink your architecture with CQRS

  • 1. Change the Rules Rethink you architecture with CQRS
  • 2. Change the Rules Who are those guys? INTRODUCTION
  • 5. Change the Rules Agenda • Introduction • Current architectures & problems • CQRS • Food for thought
  • 7. Change the Rules Huidige architecturen bron: .NET Application Architecture Guide 2.0
  • 8. Change the Rules Huidige architecturen Presentation layer Application layer Data layer
  • 9. Change the Rules multi-tier Presentation layer Domain layer Data layer
  • 10. Change the Rules Update DTO Presentation layer Request DTO Map DTO Domain layer Request Request DTO DTO Map DTO Map DTO Data layer Query data Query data Query data Query data
  • 11. Change the Rules Update DTO Presentation layer Request Send DTO DTO Map DTO Map DTO Domain layer Request Request Send Send DTO DTO DTO DTO Map DTO Map DTO Map DTO Map DTO Data layer Query data Query data Query data Query data Write data Write data Write data Write data
  • 12. Change the Rules “A single model cannot be appropriate for reporting, searching, and transactional behaviors.” – Greg Young
  • 13. Change the Rules “Doordat software processen kan automatiseren stelt het ons in staat deze verder op te schalen dan ooit tevoren.“
  • 14. Change the Rules “Every method should either be a command that performs an action, or a query that returns data to the caller, but not both.” – Bertrand Meyer
  • 15. Change the Rules Presentation layer Domain layer Data layer
  • 16. Change the Rules Presentation layer Data layer Domain layer
  • 17. Change the Rules Presentation layer Data layer Domain layer
  • 18. Change the Rules Presentation layer Read focus State transition focus Data layer Domain layer
  • 19. Change the Rules Presentation layer Queries Commands Read focus State transition focus Data layer Domain layer
  • 20. Change the Rules Presentation layer Queries Commands Read focus State transities focus Read layer Domain layer
  • 21. Change the Rules Here we go! FROM CONCEPT TO ARCHITECTUUR
  • 23. Change the Rules Queries • Requests information • Is context dependant • Is executed many times • Should be simple (select * from x where y) • Examples: – Get all products for user X – Get total price of all orders of month May
  • 24. Change the Rules Read side User interface
  • 25. Change the Rules Read side Read databases User interface
  • 26. Change the Rules Read side Read databases Facade User interface
  • 27. Change the Rules Read side Read databases Facade DTO’s User interface
  • 28. Change the Rules Read side • Focus on data needs • Optimized for reading • Can contain multiple models if needed • Can be denormalized • Facades should be minimized
  • 29. Change the Rules “State transitions are an important part of our problem space and should be modeled within our domain.” – Greg Young
  • 30. Change the Rules Commands • Causes a state transition • Contains the intend of the user • Exists in a bounded context • Examples: – AddProductToShoppingCart – PurchaseOrder – MoveUserToNewAddress – CorrectAddressForUser
  • 31. Change the Rules Commands example Create Remove Add item Add item Add item Purchase Cart item
  • 32. Change the Rules Write side Read side Read databases Facade Commandhandlers commands DTO’s User interface
  • 33. Change the Rules Command handler sample
  • 34. Change the Rules The domain • Validates and handles commands • Encapsulates behavior • Build with rich object oriented techniques
  • 35. Change the Rules Write side Read side Read databases Repository Domein Facade Commandhandlers commands DTO’s User interface
  • 36. Change the Rules Write side Read side ? Read databases Repository Domein Facade Commandhandlers commands DTO’s User interface
  • 37. Change the Rules Domain events • Result of a command • Represents a event • Examples – ProductAddedToShoppingCart – OrderPurchased – UserMovedToNewAddress – AddressCorrectedForUser
  • 39. Change the Rules Write side Read side ? Read databases Repository Domein Facade Commandhandlers commands DTO’s User interface
  • 40. Change the Rules Write side Read side Denormalizers Event bus events events events Read databases Repository Domein Facade Commandhandlers commands DTO’s User interface
  • 42. Change the Rules Write side Read side Denormalizers Event bus events events events events Event store Read databases Repository Domein Facade Commandhandlers commands DTO’s User interface
  • 43. Change the Rules Event store • Contains all domain events • Does not need to be relational • Contains the audit log • Read models can (re)build themself of it • The domain uses it to get the current state
  • 44. Change the Rules Write side Read side Denormalizers Event bus events events events events queue Event store Read databases Repository Domein Facade Commandhandlers commands DTO’s User interface
  • 46. Change the Rules CQRS Wrapup • The domain receives commands and publishes domain events. • All state changes are represented by domain Events • The read models are updated as a result of the published Events • All Queries go directly to the read models, the domain model is not involved
  • 47. Change the Rules Benefits • Fully encapsulated domain that only exposes behavior
  • 48. Change the Rules Benefits • Fully encapsulated domain that only exposes behavior • Keep users intent
  • 49. Change the Rules Benefits • Fully encapsulated domain that only exposes behavior • Keep users intent • Bullet-proof auditing and historical tracing
  • 50. Change the Rules Benefits • Fully encapsulated domain that only exposes behavior • Keep users intent • Bullet-proof auditing and historical tracing • No object-relational impedance mismatch
  • 51. Change the Rules Benefits • Fully encapsulated domain that only exposes behavior • Keep users intent • Bullet-proof auditing and historical tracing • No object-relational impedance mismatch • Optimized and multiple read models
  • 52. Change the Rules Benefits • Fully encapsulated domain that only exposes behavior • Keep users intent • Bullet-proof auditing and historical tracing • No object-relational impedance mismatch • Optimized and multiple read models • Testability
  • 53. Change the Rules Benefits • Fully encapsulated domain that only exposes behavior • Keep users intent • Bullet-proof auditing and historical tracing • No object-relational impedance mismatch • Optimized and multiple read models • Testability • Easy integration with external systems
  • 54. Change the Rules Consequences • Learning curve • Overhead for simple CRUD • Data duplication • Introducing an new architecture has a big impact
  • 55. Change the Rules Food for thought • Should your read model even contains a relational database? • What does this mean for requirement engineering? • What does this mean for outsourcing? • What does this mean for DBA?
  • 56. Change the Rules You’ve been a great audience!
  • 57. Change the Rules Reference material • Podcast with Greg Young • MyShop reference architecture • Ncqrs framework • InfoQ: Unshackle Your Domain