SlideShare uma empresa Scribd logo
1 de 56
CQRS – Eine Einführung
Pt. 2 – Event-Centric Architecture
                                      .Net Online Usergroup – 20.02.2011

                                                  Presenter: Dennis Traub

                   Speaker, Trainer, Author, Software Developer since 1991

                                                        Twitter: @DTraub
CQRS Revisited

Domain Events

An Event-Centric Architecture

Some Code

What about Testing?

Summary
CQRS revisited

                     Data Storage


               ORM                 Thin Read Layer

         Domain Model

       Command Handlers


    Commands                                Queries

                          Client
CQRS Revisited

Domain Events

An Event-Centric Architecture

Some Code

What about Testing?

Summary
Definition: Domain Event
• Martin Fowler: (PEAA, 2002)
 ▫ Captures the memory of something interesting
   which affects the domain

 ▫ The essence […] is to capture things that can
   trigger a change to the state

 ▫ These event objects are then processed to cause
   changes to the system, and stored to provide an
   audit log
State


        Shopping Cart
What we dont know:
What led to this state?
Added
  to
 Cart
Added   Added
  to      to
 Cart    Cart
Added   Added   Added
  to      to      to
 Cart    Cart    Cart
Added   Added   Added   Removed
  to      to      to      from
 Cart    Cart    Cart     Cart
Which model contains
 more Information?
This one?


            Shopping Cart
Or this one?




 Added    Added   Added   Removed
   to       to      to      from
  Cart     Cart    Cart     Cart
What if we capture every single event?
And reproduce state from
 this stream of events?
An Event Stream …


Added   Added   Added   Removed
  to      to      to      from
 Cart    Cart    Cart     Cart
An Event Stream …


Added      Added          Added   Removed
  to         to             to      from
 Cart       Cart           Cart     Cart




                                            Shopping
                                              Cart
 Can be projected into:
An Event Stream …


Added          Added      Added   Removed
  to             to         to      from
 Cart           Cart       Cart     Cart




                                            Sales History
                                                     Shopping
                                                        Cart
        … or into this:
An Event Stream …


Added          Added      Added   Removed
  to             to         to      from
 Cart           Cart       Cart     Cart




                                            Sales History
                                              Audit Trail
                                                     Shopping
                                                        Cart
        … or into this:
An Event Stream …


Added          Added      Added   Removed
  to             to         to      from
 Cart           Cart       Cart     Cart




                                       Sales History
                                    Campaign Effectiveness
                                                Shopping
                                     Campaign Effectiveness
                                                   Cart
        … or into this:
CQRS Revisited

Domain Events

Towards an Event-Centric Architecture

Some Code

What about Testing?

Summary
Simple CQRS
     Relational Data                 SQL
         Storage                    Views


           ORM                  Thin Read Layer

     Domain Model

   Command Handlers


Commands                                 Queries

                       Client
Optimized Write / Complex to Read
                       INNER JOIN …
                       LEFT OUTER JOIN …
     Relational Data   UNION …                  SQL
         Storage       GROUP BY …              Views


           ORM                             Thin Read Layer

     Domain Model

   Command Handlers


Commands                                            Queries

                         Client
Optimized Write / Complex to Read
                       INNER JOIN …
                       LEFT OUTER JOIN …
     Relational Data   UNION …                  SQL
         Storage       GROUP BY …              Views


           ORM                             Thin Read Layer

     Domain Model

   Command Handlers


Commands                                            Queries

                         Client
Replace Views with Table per Query
                                SELECT * FROM …


                                                  Table
     Relational Data                               per
         Storage                                  Query



           ORM                             Thin Read Layer

     Domain Model

   Command Handlers


Commands                                                  Queries

                       Client
Emit Events when they occur
                                     Table
     Relational Data                  per
         Storage                     View



           ORM                  Thin Read Layer

     Domain Model

   Command Handlers


Commands                                     Queries

                       Client
Denormalize Events into Read Model




                                Denormalizer
                                                    Table
     Relational Data                                 per
         Storage                                    View



           ORM                                 Thin Read Layer

     Domain Model

   Command Handlers


Commands                                                    Queries

                       Client
Add an Event Log for future retrieval




                                Denormalizer
                                                    Table
     Relational Data                                 per
         Storage                                    View



           ORM                                 Thin Read Layer

     Domain Model

   Command Handlers


Commands                Event Log                           Queries

                       Client
Simplified:

                   Events

          Domain             Read Model



   Commands                         DTOs



                    Client
CQRS Revisited

Domain Events

Towards an Event-Centric Architecture

Some Code

What about Testing?

Summary
Denormalized Store:
If ISBN exists in ShoppingCartDetails
    Increase Amount
Else
    Add New Row
Denormalized Store:
If Shopping Cart ID exists in ShoppingCartSummary
    Increase Number of Items
    Add Offered Price to Total Amount
Else
    Add New Row
Denormalized Store:
If Amount > 1 in ShoppingCartDetails
    Decrease Amount
Else
    Delete Row
Denormalized Store:
Subtract Offered Price from Total Amount
Decrease Number of Items
CQRS Revisited

Domain Events

Towards an Event-Centric Architecture

Some Code

What about Testing?

Summary
Testing the Read Model




                  Denormalizer
                                      Table
                                       per
                                      View



                                 Thin Read Layer
Testing the Read Model
Given that certain Events have occurred




                                          Denormalizer
                                                              Table
                                                               per
                                                              View



                                                         Thin Read Layer
Testing the Read Model
Given that certain Events have occurred




                                          Denormalizer
                                                              Table
                                                               per
When a specific Event has occurred                            View



                                                         Thin Read Layer
Testing the Read Model
Given that certain Events have occurred




                                          Denormalizer
                                                              Table
                                                               per
When a specific Event has occurred                            View



                                                         Thin Read Layer




Then each query should produce the expected results
Testing the Read Model

Given that a book with an ISBN of xxx and a
      price of USD 24.00 was added to a new shopping cart

When   a book with an ISBN of yyy and a price
       of USD 19.00 was added to that same shopping cart

Then   the Shopping Cart Summary should contain 2 books
       and have a total amount of USD 43.00

And    the Shopping Cart Details should contain book xxx

And    the Shopping Cart Details should contain book yyy
Testing the Write Model



    Domain Model

  Command Handlers
Testing the Write Model



                     Given that certain Events have occurred
    Domain Model

  Command Handlers
Testing the Write Model



                      Given that certain Events have occurred
     Domain Model

   Command Handlers

                           When a specific Commands is sent
Commands
Testing the Write Model
             Then the expected Events (and only those) should be emitted




                                 Given that certain Events have occurred
     Domain Model

   Command Handlers

                                      When a specific Commands is sent
Commands
Testing the Write Model

Given that an Add Book To Shopping Cart event with
      an ISBN of xxx had been sent

When   a Remove Book From Shopping Cart command is
       sent with an ISBN of zzz

Then   a Book Removal Failed event should be emitted

And    NO Book Was Removed From Shopping Cart event
       should be emitted
CQRS Revisited

Domain Events

Towards an Event-Centric Architecture

Some Code

What about Testing?

Summary
Main Value:
• Additive only, i.e. we don‘t lose information

• Linearly scalable and distributable Read Model

• Every new view can be created from the
  beginning of time

• We can come up with new questions at any time

• Built-In Integration Model
Proven Technology:
Mature business models move away from
Update/Delete and become purely transactional:

 ▫   Human Resources   ▫ Banking
 ▫   Medicine          ▫ Financial Trading
 ▫   Bookkeeping       ▫ Government
 ▫   …
What we haven‘t touched yet:


 ▫ Messaging        ▫ Eventual Consistency
 ▫ Event Sourcing   ▫ Integration Scenarios
 ▫ Sagas            ▫…
Resources
• http:// cqrs.wordpress.com

• http:// groups.google.com/group/dddcqrs

• http:// distributedpodcast.com

• http:// abdullin.com/cqrs

• http://cqrs.wikidot.com
Vielen Dank!
     Dennis Traub
          @Dtraub

  Please rate this talk at:
    bit.ly/xyb4tx

Mais conteúdo relacionado

Semelhante a CQRS-Einführung - Teil 2

EventDrivenArchitecture
EventDrivenArchitectureEventDrivenArchitecture
EventDrivenArchitecture
Hiroshi Ono
 
Event Driven Architecture
Event Driven ArchitectureEvent Driven Architecture
Event Driven Architecture
andreaskallberg
 
MS TechDays 2011 - Automating Your Infrastructure System Center Orchestrator ...
MS TechDays 2011 - Automating Your Infrastructure System Center Orchestrator ...MS TechDays 2011 - Automating Your Infrastructure System Center Orchestrator ...
MS TechDays 2011 - Automating Your Infrastructure System Center Orchestrator ...
Spiffy
 
13h00 p duff-building-applications-with-aws-final
13h00   p duff-building-applications-with-aws-final13h00   p duff-building-applications-with-aws-final
13h00 p duff-building-applications-with-aws-final
Luiz Gustavo Santos
 

Semelhante a CQRS-Einführung - Teil 2 (20)

Lets focus on business value
Lets focus on business valueLets focus on business value
Lets focus on business value
 
Lets focus on business value
Lets focus on business valueLets focus on business value
Lets focus on business value
 
Lets focus on business value
Lets focus on business valueLets focus on business value
Lets focus on business value
 
EventDrivenArchitecture
EventDrivenArchitectureEventDrivenArchitecture
EventDrivenArchitecture
 
Event Sourcing & CQRS: Down the rabbit hole
Event Sourcing & CQRS: Down the rabbit holeEvent Sourcing & CQRS: Down the rabbit hole
Event Sourcing & CQRS: Down the rabbit hole
 
Event Driven Architecture
Event Driven ArchitectureEvent Driven Architecture
Event Driven Architecture
 
Event Driven Architecture
Event Driven ArchitectureEvent Driven Architecture
Event Driven Architecture
 
Analytics at Scale with Apache Spark on AWS with Jonathan Fritz
Analytics at Scale with Apache Spark on AWS with Jonathan FritzAnalytics at Scale with Apache Spark on AWS with Jonathan Fritz
Analytics at Scale with Apache Spark on AWS with Jonathan Fritz
 
Azure and cloud design patterns
Azure and cloud design patternsAzure and cloud design patterns
Azure and cloud design patterns
 
Event Driven-Architecture from a Scalability perspective
Event Driven-Architecture from a Scalability perspectiveEvent Driven-Architecture from a Scalability perspective
Event Driven-Architecture from a Scalability perspective
 
arch_mtg_sqlsig_hcotter_replication.ppt
arch_mtg_sqlsig_hcotter_replication.pptarch_mtg_sqlsig_hcotter_replication.ppt
arch_mtg_sqlsig_hcotter_replication.ppt
 
Overcoming the Top Four Challenges to Real-Time Performance in Large-Scale, D...
Overcoming the Top Four Challenges to Real-Time Performance in Large-Scale, D...Overcoming the Top Four Challenges to Real-Time Performance in Large-Scale, D...
Overcoming the Top Four Challenges to Real-Time Performance in Large-Scale, D...
 
Balancing Replication and Partitioning in a Distributed Java Database
Balancing Replication and Partitioning in a Distributed Java DatabaseBalancing Replication and Partitioning in a Distributed Java Database
Balancing Replication and Partitioning in a Distributed Java Database
 
MS TechDays 2011 - Automating Your Infrastructure System Center Orchestrator ...
MS TechDays 2011 - Automating Your Infrastructure System Center Orchestrator ...MS TechDays 2011 - Automating Your Infrastructure System Center Orchestrator ...
MS TechDays 2011 - Automating Your Infrastructure System Center Orchestrator ...
 
Exploring CQRS and Event Sourcing
Exploring CQRS and Event SourcingExploring CQRS and Event Sourcing
Exploring CQRS and Event Sourcing
 
게임을 위한 Cloud Native on AWS (김일호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018
게임을 위한 Cloud Native on AWS (김일호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018게임을 위한 Cloud Native on AWS (김일호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018
게임을 위한 Cloud Native on AWS (김일호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018
 
13h00 p duff-building-applications-with-aws-final
13h00   p duff-building-applications-with-aws-final13h00   p duff-building-applications-with-aws-final
13h00 p duff-building-applications-with-aws-final
 
Introduction to AWS tools
Introduction to AWS toolsIntroduction to AWS tools
Introduction to AWS tools
 
Building Applications with AWS
Building Applications with AWSBuilding Applications with AWS
Building Applications with AWS
 
AWS case study: real estate portal
AWS case study: real estate portalAWS case study: real estate portal
AWS case study: real estate portal
 

Mais de Dennis Traub

Strategic Appplication Development with Domain-Driven Design (DDD)
Strategic Appplication Development with Domain-Driven Design (DDD)Strategic Appplication Development with Domain-Driven Design (DDD)
Strategic Appplication Development with Domain-Driven Design (DDD)
Dennis Traub
 

Mais de Dennis Traub (7)

Application Integration Patterns (not only) for Microservices
Application Integration Patterns (not only) for MicroservicesApplication Integration Patterns (not only) for Microservices
Application Integration Patterns (not only) for Microservices
 
Serverless SecOps Automation on AWS at AWS UG Krakow, Poland
Serverless SecOps Automation on AWS at AWS UG Krakow, PolandServerless SecOps Automation on AWS at AWS UG Krakow, Poland
Serverless SecOps Automation on AWS at AWS UG Krakow, Poland
 
Serverless Security Automation on AWS - Hamburg AWS User Group
Serverless Security Automation on AWS - Hamburg AWS User GroupServerless Security Automation on AWS - Hamburg AWS User Group
Serverless Security Automation on AWS - Hamburg AWS User Group
 
Cloud ist keine Strategie - Keynote des AWS Cloud Day, Solingen
Cloud ist keine Strategie - Keynote des AWS Cloud Day, SolingenCloud ist keine Strategie - Keynote des AWS Cloud Day, Solingen
Cloud ist keine Strategie - Keynote des AWS Cloud Day, Solingen
 
Cloud ist keine Strategie - AWS Tech Community Summit Cologne, 2017
Cloud ist keine Strategie - AWS Tech Community Summit Cologne, 2017Cloud ist keine Strategie - AWS Tech Community Summit Cologne, 2017
Cloud ist keine Strategie - AWS Tech Community Summit Cologne, 2017
 
Strategic Appplication Development with Domain-Driven Design (DDD)
Strategic Appplication Development with Domain-Driven Design (DDD)Strategic Appplication Development with Domain-Driven Design (DDD)
Strategic Appplication Development with Domain-Driven Design (DDD)
 
Strategischer Anwendungsentwurf mit Domain-Driven Design
Strategischer Anwendungsentwurf mit Domain-Driven DesignStrategischer Anwendungsentwurf mit Domain-Driven Design
Strategischer Anwendungsentwurf mit Domain-Driven Design
 

Último

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 

Último (20)

ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 

CQRS-Einführung - Teil 2

  • 1. CQRS – Eine Einführung Pt. 2 – Event-Centric Architecture .Net Online Usergroup – 20.02.2011 Presenter: Dennis Traub Speaker, Trainer, Author, Software Developer since 1991 Twitter: @DTraub
  • 2. CQRS Revisited Domain Events An Event-Centric Architecture Some Code What about Testing? Summary
  • 3. CQRS revisited Data Storage ORM Thin Read Layer Domain Model Command Handlers Commands Queries Client
  • 4. CQRS Revisited Domain Events An Event-Centric Architecture Some Code What about Testing? Summary
  • 5. Definition: Domain Event • Martin Fowler: (PEAA, 2002) ▫ Captures the memory of something interesting which affects the domain ▫ The essence […] is to capture things that can trigger a change to the state ▫ These event objects are then processed to cause changes to the system, and stored to provide an audit log
  • 6. State Shopping Cart
  • 7. What we dont know: What led to this state?
  • 8. Added to Cart
  • 9. Added Added to to Cart Cart
  • 10. Added Added Added to to to Cart Cart Cart
  • 11. Added Added Added Removed to to to from Cart Cart Cart Cart
  • 12. Which model contains more Information?
  • 13. This one? Shopping Cart
  • 14. Or this one? Added Added Added Removed to to to from Cart Cart Cart Cart
  • 15. What if we capture every single event?
  • 16. And reproduce state from this stream of events?
  • 17. An Event Stream … Added Added Added Removed to to to from Cart Cart Cart Cart
  • 18. An Event Stream … Added Added Added Removed to to to from Cart Cart Cart Cart Shopping Cart Can be projected into:
  • 19. An Event Stream … Added Added Added Removed to to to from Cart Cart Cart Cart Sales History Shopping Cart … or into this:
  • 20. An Event Stream … Added Added Added Removed to to to from Cart Cart Cart Cart Sales History Audit Trail Shopping Cart … or into this:
  • 21. An Event Stream … Added Added Added Removed to to to from Cart Cart Cart Cart Sales History Campaign Effectiveness Shopping Campaign Effectiveness Cart … or into this:
  • 22. CQRS Revisited Domain Events Towards an Event-Centric Architecture Some Code What about Testing? Summary
  • 23. Simple CQRS Relational Data SQL Storage Views ORM Thin Read Layer Domain Model Command Handlers Commands Queries Client
  • 24. Optimized Write / Complex to Read INNER JOIN … LEFT OUTER JOIN … Relational Data UNION … SQL Storage GROUP BY … Views ORM Thin Read Layer Domain Model Command Handlers Commands Queries Client
  • 25. Optimized Write / Complex to Read INNER JOIN … LEFT OUTER JOIN … Relational Data UNION … SQL Storage GROUP BY … Views ORM Thin Read Layer Domain Model Command Handlers Commands Queries Client
  • 26. Replace Views with Table per Query SELECT * FROM … Table Relational Data per Storage Query ORM Thin Read Layer Domain Model Command Handlers Commands Queries Client
  • 27. Emit Events when they occur Table Relational Data per Storage View ORM Thin Read Layer Domain Model Command Handlers Commands Queries Client
  • 28. Denormalize Events into Read Model Denormalizer Table Relational Data per Storage View ORM Thin Read Layer Domain Model Command Handlers Commands Queries Client
  • 29. Add an Event Log for future retrieval Denormalizer Table Relational Data per Storage View ORM Thin Read Layer Domain Model Command Handlers Commands Event Log Queries Client
  • 30. Simplified: Events Domain Read Model Commands DTOs Client
  • 31. CQRS Revisited Domain Events Towards an Event-Centric Architecture Some Code What about Testing? Summary
  • 32.
  • 33.
  • 34.
  • 35. Denormalized Store: If ISBN exists in ShoppingCartDetails Increase Amount Else Add New Row
  • 36. Denormalized Store: If Shopping Cart ID exists in ShoppingCartSummary Increase Number of Items Add Offered Price to Total Amount Else Add New Row
  • 37.
  • 38. Denormalized Store: If Amount > 1 in ShoppingCartDetails Decrease Amount Else Delete Row
  • 39. Denormalized Store: Subtract Offered Price from Total Amount Decrease Number of Items
  • 40. CQRS Revisited Domain Events Towards an Event-Centric Architecture Some Code What about Testing? Summary
  • 41. Testing the Read Model Denormalizer Table per View Thin Read Layer
  • 42. Testing the Read Model Given that certain Events have occurred Denormalizer Table per View Thin Read Layer
  • 43. Testing the Read Model Given that certain Events have occurred Denormalizer Table per When a specific Event has occurred View Thin Read Layer
  • 44. Testing the Read Model Given that certain Events have occurred Denormalizer Table per When a specific Event has occurred View Thin Read Layer Then each query should produce the expected results
  • 45. Testing the Read Model Given that a book with an ISBN of xxx and a price of USD 24.00 was added to a new shopping cart When a book with an ISBN of yyy and a price of USD 19.00 was added to that same shopping cart Then the Shopping Cart Summary should contain 2 books and have a total amount of USD 43.00 And the Shopping Cart Details should contain book xxx And the Shopping Cart Details should contain book yyy
  • 46. Testing the Write Model Domain Model Command Handlers
  • 47. Testing the Write Model Given that certain Events have occurred Domain Model Command Handlers
  • 48. Testing the Write Model Given that certain Events have occurred Domain Model Command Handlers When a specific Commands is sent Commands
  • 49. Testing the Write Model Then the expected Events (and only those) should be emitted Given that certain Events have occurred Domain Model Command Handlers When a specific Commands is sent Commands
  • 50. Testing the Write Model Given that an Add Book To Shopping Cart event with an ISBN of xxx had been sent When a Remove Book From Shopping Cart command is sent with an ISBN of zzz Then a Book Removal Failed event should be emitted And NO Book Was Removed From Shopping Cart event should be emitted
  • 51. CQRS Revisited Domain Events Towards an Event-Centric Architecture Some Code What about Testing? Summary
  • 52. Main Value: • Additive only, i.e. we don‘t lose information • Linearly scalable and distributable Read Model • Every new view can be created from the beginning of time • We can come up with new questions at any time • Built-In Integration Model
  • 53. Proven Technology: Mature business models move away from Update/Delete and become purely transactional: ▫ Human Resources ▫ Banking ▫ Medicine ▫ Financial Trading ▫ Bookkeeping ▫ Government ▫ …
  • 54. What we haven‘t touched yet: ▫ Messaging ▫ Eventual Consistency ▫ Event Sourcing ▫ Integration Scenarios ▫ Sagas ▫…
  • 55. Resources • http:// cqrs.wordpress.com • http:// groups.google.com/group/dddcqrs • http:// distributedpodcast.com • http:// abdullin.com/cqrs • http://cqrs.wikidot.com
  • 56. Vielen Dank! Dennis Traub @Dtraub Please rate this talk at: bit.ly/xyb4tx

Notas do Editor

  1. Refactor Application Service Call to Object => CommandCommands can
  2. Refactor Application Service Call to Object => CommandCommands can
  3. Refactor Application Service Call to Object => CommandCommands can
  4. Refactor Application Service Call to Object => CommandCommands can
  5. Refactor Application Service Call to Object => CommandCommands can
  6. Refactor Application Service Call to Object => CommandCommands can
  7. Refactor Application Service Call to Object => CommandCommands can
  8. Refactor Application Service Call to Object => CommandCommands can
  9. Refactor Application Service Call to Object => CommandCommands can
  10. Refactor Application Service Call to Object => CommandCommands can
  11. Refactor Application Service Call to Object => CommandCommands can
  12. Refactor Application Service Call to Object => CommandCommands can
  13. Refactor Application Service Call to Object => CommandCommands can
  14. Refactor Application Service Call to Object => CommandCommands can
  15. Refactor Application Service Call to Object => CommandCommands can
  16. Refactor Application Service Call to Object => CommandCommands can
  17. Refactor Application Service Call to Object => CommandCommands can
  18. Refactor Application Service Call to Object => CommandCommands can
  19. Refactor Application Service Call to Object => CommandCommands can
  20. Refactor Application Service Call to Object => CommandCommands can
  21. Refactor Application Service Call to Object => CommandCommands can
  22. Refactor Application Service Call to Object => CommandCommands can
  23. Refactor Application Service Call to Object => CommandCommands can
  24. Refactor Application Service Call to Object => CommandCommands can
  25. Refactor Application Service Call to Object => CommandCommands can
  26. Refactor Application Service Call to Object => CommandCommands can
  27. Refactor Application Service Call to Object => CommandCommands can
  28. Refactor Application Service Call to Object => CommandCommands can
  29. Refactor Application Service Call to Object => CommandCommands can
  30. Refactor Application Service Call to Object => CommandCommands can
  31. Refactor Application Service Call to Object => CommandCommands can
  32. Refactor Application Service Call to Object => CommandCommands can
  33. Refactor Application Service Call to Object => CommandCommands can
  34. Refactor Application Service Call to Object => CommandCommands can
  35. Refactor Application Service Call to Object => CommandCommands can