Your SlideShare is downloading. ×
CQRS-Einführung - Teil 2
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

CQRS-Einführung - Teil 2

378
views

Published on

Published in: Education, Business, Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
378
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Refactor Application Service Call to Object => CommandCommands can
  • Transcript

    • 1. CQRS – Eine EinführungPt. 2 – Event-Centric Architecture .Net Online Usergroup – 20.02.2011 Presenter: Dennis Traub Speaker, Trainer, Author, Software Developer since 1991 Twitter: @DTraub
    • 2. CQRS RevisitedDomain EventsAn Event-Centric ArchitectureSome CodeWhat about Testing?Summary
    • 3. CQRS revisited Data Storage ORM Thin Read Layer Domain Model Command Handlers Commands Queries Client
    • 4. CQRS RevisitedDomain EventsAn Event-Centric ArchitectureSome CodeWhat 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 RevisitedDomain EventsTowards an Event-Centric ArchitectureSome CodeWhat about Testing?Summary
    • 23. Simple CQRS Relational Data SQL Storage Views ORM Thin Read Layer Domain Model Command HandlersCommands 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 HandlersCommands 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 HandlersCommands Queries Client
    • 26. Replace Views with Table per Query SELECT * FROM … Table Relational Data per Storage Query ORM Thin Read Layer Domain Model Command HandlersCommands Queries Client
    • 27. Emit Events when they occur Table Relational Data per Storage View ORM Thin Read Layer Domain Model Command HandlersCommands Queries Client
    • 28. Denormalize Events into Read Model Denormalizer Table Relational Data per Storage View ORM Thin Read Layer Domain Model Command HandlersCommands Queries Client
    • 29. Add an Event Log for future retrieval Denormalizer Table Relational Data per Storage View ORM Thin Read Layer Domain Model Command HandlersCommands Event Log Queries Client
    • 30. Simplified: Events Domain Read Model Commands DTOs Client
    • 31. CQRS RevisitedDomain EventsTowards an Event-Centric ArchitectureSome CodeWhat about Testing?Summary
    • 32. Denormalized Store:If ISBN exists in ShoppingCartDetails Increase AmountElse Add New Row
    • 33. Denormalized Store:If Shopping Cart ID exists in ShoppingCartSummary Increase Number of Items Add Offered Price to Total AmountElse Add New Row
    • 34. Denormalized Store:If Amount > 1 in ShoppingCartDetails Decrease AmountElse Delete Row
    • 35. Denormalized Store:Subtract Offered Price from Total AmountDecrease Number of Items
    • 36. CQRS RevisitedDomain EventsTowards an Event-Centric ArchitectureSome CodeWhat about Testing?Summary
    • 37. Testing the Read Model Denormalizer Table per View Thin Read Layer
    • 38. Testing the Read ModelGiven that certain Events have occurred Denormalizer Table per View Thin Read Layer
    • 39. Testing the Read ModelGiven that certain Events have occurred Denormalizer Table perWhen a specific Event has occurred View Thin Read Layer
    • 40. Testing the Read ModelGiven that certain Events have occurred Denormalizer Table perWhen a specific Event has occurred View Thin Read LayerThen each query should produce the expected results
    • 41. Testing the Read ModelGiven that a book with an ISBN of xxx and a price of USD 24.00 was added to a new shopping cartWhen a book with an ISBN of yyy and a price of USD 19.00 was added to that same shopping cartThen the Shopping Cart Summary should contain 2 books and have a total amount of USD 43.00And the Shopping Cart Details should contain book xxxAnd the Shopping Cart Details should contain book yyy
    • 42. Testing the Write Model Domain Model Command Handlers
    • 43. Testing the Write Model Given that certain Events have occurred Domain Model Command Handlers
    • 44. Testing the Write Model Given that certain Events have occurred Domain Model Command Handlers When a specific Commands is sentCommands
    • 45. 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 sentCommands
    • 46. Testing the Write ModelGiven that an Add Book To Shopping Cart event with an ISBN of xxx had been sentWhen a Remove Book From Shopping Cart command is sent with an ISBN of zzzThen a Book Removal Failed event should be emittedAnd NO Book Was Removed From Shopping Cart event should be emitted
    • 47. CQRS RevisitedDomain EventsTowards an Event-Centric ArchitectureSome CodeWhat about Testing?Summary
    • 48. 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
    • 49. Proven Technology:Mature business models move away fromUpdate/Delete and become purely transactional: ▫ Human Resources ▫ Banking ▫ Medicine ▫ Financial Trading ▫ Bookkeeping ▫ Government ▫ …
    • 50. What we haven‘t touched yet: ▫ Messaging ▫ Eventual Consistency ▫ Event Sourcing ▫ Integration Scenarios ▫ Sagas ▫…
    • 51. Resources• http:// cqrs.wordpress.com• http:// groups.google.com/group/dddcqrs• http:// distributedpodcast.com• http:// abdullin.com/cqrs• http://cqrs.wikidot.com
    • 52. Vielen Dank! Dennis Traub @Dtraub Please rate this talk at: bit.ly/xyb4tx

    ×