Upgrade to Pro — share decks privately, control downloads, hide ads and more …

9 things that will make your ES/CQRS journey painful

9 things that will make your ES/CQRS journey painful

Les 9 pièges a éviter lorsque l'on démarre une implémentation ES/CQRS. Parce que de prime abord ça parait simple et qu'en fait, beaucoup se font assez mal en essayant ! On abordera : Domain-Driven Design (dont les Bounded Contexts), Event Storming, Eventual Consistency, versioning d'évènements, problématiques des systèmes distribués, Process Managers & Sagas.

Clément HELIOU

December 08, 2017
Tweet

More Decks by Clément HELIOU

Other Decks in Programming

Transcript

  1. Event Sourcing in a nutshell Time ACCOUNT id : 45

    balance : 200€ ACCOUNT id : 45 balance : 270€ ACCOUNT id : 45 balance : 110€
  2. Event Sourcing in a nutshell Time ACCOUNT OPENED id :

    45 provision : 200€ ACCOUNT CREDITED id : 45 balance : 200€ amount : 70€ ACCOUNT DEBITED id : 45 balance : 270€ amount : 160€
  3. Event Sourcing in a nutshell Aggregate “Decide” Command Jérémie Chassaing

    - http://thinkbeforecoding.com/post/2014/01/04/Event-Sourcing.-Draw-it
  4. Event Sourcing in a nutshell Aggregate “Decide” Command Events Jérémie

    Chassaing - http://thinkbeforecoding.com/post/2014/01/04/Event-Sourcing.-Draw-it +
  5. Event Sourcing in a nutshell Aggregate “Apply” Command Jérémie Chassaing

    - http://thinkbeforecoding.com/post/2014/01/04/Event-Sourcing.-Draw-it + Events “Decide”
  6. Event Sourcing in a nutshell Aggregate “Apply” Command State Events

    Jérémie Chassaing - http://thinkbeforecoding.com/post/2014/01/04/Event-Sourcing.-Draw-it + “Decide”
  7. 2 | Persist commands instead of events Aggregate “Decide” “Apply”

    Command State Events Jérémie Chassaing - http://thinkbeforecoding.com/post/2014/01/04/Event-Sourcing.-Draw-it +
  8. 2 | Persist commands instead of events Time ACCOUNT DEBITED

    id : 45 balance : 270€ amount : 160€ ACCOUNT CREDITED id : 45 balance : 110€ amount : 70€ ACCOUNT CREDITED id : 45 balance : 180€ amount : 3,51€ DEBIT ACCOUNT CREDIT ACCOUNT PAY INTERESTS
  9. 2 | Persist commands instead of events Time ACCOUNT DEBITED

    id : 45 balance : 270€ amount : 160€ ACCOUNT CREDITED id : 45 balance : 110€ amount : 70€ ACCOUNT CREDITED id : 45 balance : 180€ amount : 3,51€ DEBIT ACCOUNT CREDIT ACCOUNT PAY INTERESTS
  10. 2 | Persist commands instead of events Aggregate “Apply” Command

    State Events Jérémie Chassaing - http://thinkbeforecoding.com/post/2014/01/04/Event-Sourcing.-Draw-it + “Decide”
  11. 2 | Persist commands instead of events Aggregate “Apply” Command

    State Events Jérémie Chassaing - http://thinkbeforecoding.com/post/2014/01/04/Event-Sourcing.-Draw-it + “Decide”
  12. 2 | Persist commands instead of events Time ACCOUNT DEBITED

    id : 45 balance : 270€ amount : 160€ DEBIT ACCOUNT ACCOUNT CREDITED id : 45 balance : 110€ amount : 70€ CREDIT ACCOUNT ACCOUNT CREDITED id : 45 balance : 180€ amount : 2,36€ PAY INTERESTS
  13. 2 | Persist commands instead of events Aggregate “Apply” Command

    State Events Jérémie Chassaing - http://thinkbeforecoding.com/post/2014/01/04/Event-Sourcing.-Draw-it + “Decide”
  14. 9 things that will make your ES/CQRS journey painful Think

    of ES/CQRS as a top-level architecture 3
  15. 9 things that will make your ES/CQRS journey painful Consider

    ES/CQRS only to be a technical stuff 4
  16. 4 | Consider ES/CQRS only to be a technical stuff

    Architects Domain Model DDD Entities Aggregates Value Objects Ubiquitous Language Domain-Driven Design
  17. 4 | Consider ES/CQRS only to be a technical stuff

    Domain-Driven Design Bounded contexts = Domain Model + Ubiquitous Language Identity Core Banking System Loans
  18. 4 | Consider ES/CQRS only to be a technical stuff

    Domain-Driven Design Communication between Bounded Contexts Core Banking System Loans Loan Payment Scheduled
  19. 4 | Consider ES/CQRS only to be a technical stuff

    Event Storming from events to shared knowledge
  20. 4 | Consider ES/CQRS only to be a technical stuff

    Account opened Event Storming Step 1 - Put the events on the wall Alberto Brandolini - http://ziobrando.blogspot.fr/2013/11/introducing-event-storming.html Account debited Account closed Account credited
  21. 4 | Consider ES/CQRS only to be a technical stuff

    Account opened Event Storming Step 2 - Put the events in chronological order Time Account credited Account debited Account closed Alberto Brandolini - http://ziobrando.blogspot.fr/2013/11/introducing-event-storming.html
  22. 4 | Consider ES/CQRS only to be a technical stuff

    Event 2 Command Event Storming Step 3 - Discover what does trigger events (aka. the actions) External System End of Month Event 1 Actor Something magic happening here Alberto Brandolini - http://ziobrando.blogspot.fr/2013/11/introducing-event-storming.html
  23. 4 | Consider ES/CQRS only to be a technical stuff

    Account opened Open account Event Storming Step 3 - Discover what does trigger events (aka. the actions) Client Account debited End of Month Alberto Brandolini - http://ziobrando.blogspot.fr/2013/11/introducing-event-storming.html
  24. 4 | Consider ES/CQRS only to be a technical stuff

    Event Storming Step 4 - Group events/actions by aggregate Account opened Open account Client Account closed Account credited Account debited End of Month Close account Alberto Brandolini - http://ziobrando.blogspot.fr/2013/11/introducing-event-storming.html Account Credit account Client
  25. 4 | Consider ES/CQRS only to be a technical stuff

    Event Storming Step 5 - Group aggregates by bounded contexts Alberto Brandolini - http://ziobrando.blogspot.fr/2013/11/introducing-event-storming.html Account Session User identity Identity BC Core BC
  26. 9 things that will make your ES/CQRS journey painful Do

    not embrace eventual consistency 5
  27. 6 | To be unaware of events evolution Aggregate “Apply”

    Command State Events Jérémie Chassaing - http://thinkbeforecoding.com/post/2014/01/04/Event-Sourcing.-Draw-it + “Decide”
  28. 6 | To be unaware of events evolution Aggregate “Apply”

    Command State Events Jérémie Chassaing - http://thinkbeforecoding.com/post/2014/01/04/Event-Sourcing.-Draw-it + “Decide”
  29. 6 | To be unaware of events evolution Bounded Contexts

    Core Banking System Loans Loan Payment Scheduled ACL Protect them with Anti-Corruption Layers (ACL)
  30. 9 things that will make your ES/CQRS journey painful Ignore

    the 4 challenges of messaging systems 7
  31. Duplicated messages Lost messages Out-of-order messages Unprocessed messages The 4

    challenges of messaging systems An error in the messaging infrastructure may cause a message not to be delivered to its recipient. An error in the messaging infrastructure or in the receiving code may cause a message to be delivered multiple times to its recipient. The messaging infrastructure may deliver messages to a recipient in different order than the sender’s one. A client may retrieve a message from a queue and then fail to process it. Consequently, the message has been lost. 7 | Ignore the 4 challenges of messaging systems
  32. 9 things that will make your ES/CQRS journey painful Not

    to be able to easily switch any piece of technology 8
  33. 8 | Not to be able to easily switch any

    piece of technology Commands Aggregate Projections Queries Events Events +
  34. Process Managers 9 | Lack of Process Managers and Sagas

    Visualize your business workflows Execution Requesting Quote Requesting Quoting Booking Hedging S E Quote Requested Quote Received Quote Received Execution Requested Execution Accepted Booking Succeeded Execution Hedged
  35. 9 | Lack of Process Managers and Sagas Sagas Removing

    the use of a distributed transaction Loans Core Banking System
  36. 9 | Lack of Process Managers and Sagas Sagas Execution

    Requesting Credit Reserving Credit Cancelling Credit Confirming Execution Requested Credit Reserved Execution Rejected Execution Accepted Removing the use of a distributed transaction
  37. 9 things that will make your ES/CQRS journey painful Resources

    ➲ Exploring CQRS and Event Sourcing ⤷ D. Betts, J. Dominguez, G. Melnik, F. Simonazzi, M. Subramanian ➲ CQRS:ES from Scratch ⤷ E. Pecoul, F. Pellet ➲ A Decade of DDD, CQRS, Event Sourcing ⤷ G. Young ➲ Event Sourcing Versioning ⤷ R. Abdullin ➲ Event Storming Recipes ⤷ A. Brandolini