Cqrs race conditions_and_sagas_ohmy

5,745 views

Published on

Published in: Technology, News & Politics
0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,745
On SlideShare
0
From Embeds
0
Number of Embeds
2,657
Actions
Shares
0
Downloads
70
Comments
0
Likes
6
Embeds 0
No embeds

No notes for slide
  • This is a fact of life – like gravity – you can’t fight it.
  • We see this on Twitter and Facebook – telling us how long ago something happened
  • Don’t need all data in the DB or in the rules – what needs to be in there?
  • If a use clicked a button a microsecond earlier or later, that shouldn’t change fundamental business objectives.
  • Race conditions will cause many commands to fail, undoing much of the foundation of CQRS
  • Which indicates that there’s a bug in the requirements
  • Cqrs race conditions_and_sagas_ohmy

    1. 1. CQRS Races Sagas Domain Model
    2. 2. Get dataGet data Change dataUser is looking at stale data
    3. 3. Data correct as of 10 minutes ago List of customers
    4. 4. List of customers Customer Service Rep view ID Name Phone List of customers Supervisor view ID Name Phone Lifetime value
    5. 5. Queries Commands DB Service Layer Input Validation Validation Rules Queries View Model View Model Updater Publish Client
    6. 6. Cancel OrderShip Order Rules: 1. Cannot cancel shipped orders 2. Don’t ship cancelled orders
    7. 7. public class Order { public void Cancel() { if (status != OrderStatusEnum.Shipped) //cancel } public void Ship() { if (status != OrderStatusEnum.Cancelled) //ship } }
    8. 8. Looks like we’re stuck
    9. 9. The customer doesn’t want the products No point in arguing
    10. 10. Rules: 1. Cannot cancel shipped orders Because shipping costs money That money would be lost if the customer cancelled Because we refund the customers money 2. Don’t ship cancelled orders
    11. 11. www.NServiceBus.com
    12. 12. Queries Commands DB Service Layer Input Validation Validation Rules Queries View Model View Model Updater Publish Client
    13. 13. CQRS Races Sagas Domain Model

    ×