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

CQRS/EventSourcing certains en parlent, nous les avons implémentés !

CQRS/EventSourcing certains en parlent, nous les avons implémentés !

L’Event Sourcing et CQRS sont sur toutes les lèvres en cette année 2016 qui marque l’avènement des systèmes dits « réactifs » ou « dirigés par les évènements ». Bien que leur présence ne date pas d’hier, peu d’applications en tire aujourd’hui bénéfice. Dans ce retour d’expérience, nous allons vous présenter dans le détail et en toute transparence, l’implémentation mise en place au sein d’une grande banque d’investissement française, ses avantages, ses inconvénients et les leçons que nous avons en tiré. Nous espérons vous donner ainsi le bagage nécessaire pour vous lancer à votre tour dans la grande aventure du réactif.

Clément HELIOU

November 09, 2016
Tweet

More Decks by Clément HELIOU

Other Decks in Programming

Transcript

  1. @c_heliou @xebiconfr #xebiconfr 4 « Capturer tous les changements d’état

    d’une application comme une séquence d’évènements » Martin Fowler
  2. @c_heliou @xebiconfr #xebiconfr 5 Date Débit Crédit 2016/05/14 100 €

    2016/05/14 -20 € 2016/05/16 -30 € 2016/05/24 380 € 2016/06/01 -70 € Total -120 € 480 € Solde 360 €
  3. @c_heliou @xebiconfr #xebiconfr 7 Application Inspiré par J. Chassaing -

    http://thinkbeforecoding.com/post/2014/01/04/Event-Sourcing.-Draw-it Commande Fonction de
 Décision
  4. @c_heliou @xebiconfr #xebiconfr 9 Application Inspiré par J. Chassaing -

    http://thinkbeforecoding.com/post/2014/01/04/Event-Sourcing.-Draw-it Fonction de
 Décision Commande Fonction 
 d’évolution Évènement(s) Event store
  5. @c_heliou @xebiconfr #xebiconfr 10 Fonction d’évolution (état courant + évènement)

    => nouvel état Pour chaque évènement émis par 
 la fonction de décision
  6. @c_heliou @xebiconfr #xebiconfr 11 Application Inspiré par J. Chassaing -

    http://thinkbeforecoding.com/post/2014/01/04/Event-Sourcing.-Draw-it Évènement(s) Fonction de
 Décision Commande Fonction 
 d’évolution Event store Action Effets de bord
  7. @c_heliou @xebiconfr #xebiconfr 19 Application Inspiré par J. Chassaing -

    http://thinkbeforecoding.com/post/2014/01/04/Event-Sourcing.-Draw-it Fonction de
 Décision RecevoirPrix
 {commande}
  8. @c_heliou @xebiconfr #xebiconfr 22 Application Inspiré par J. Chassaing -

    http://thinkbeforecoding.com/post/2014/01/04/Event-Sourcing.-Draw-it Fonction de
 Décision RecevoirPrix
 {commande} Fonction 
 d’évolution PrixReçu
 {évènement}
  9. @c_heliou @xebiconfr #xebiconfr 24 Application Inspiré par J. Chassaing -

    http://thinkbeforecoding.com/post/2014/01/04/Event-Sourcing.-Draw-it Fonction de
 Décision RecevoirPrix
 {commande} Fonction 
 d’évolution PrixReçu
 {évènement} Demande de prix Réception de prix PrixReçu
 {évènement} TransférerPrix
 {action} PrixTransféré
 {évènement}
  10. @c_heliou @xebiconfr #xebiconfr 26 Bus Handler Handler EMS thread pool

    IUM thread pool EMS thread pool IUM thread pool Event loop Commandes Évènements Messages Messages
  11. @c_heliou @xebiconfr #xebiconfr 27 Bus Handler Handler EMS thread pool

    IUM thread pool EMS thread pool IUM thread pool Event loop Commandes Évènements Messages Messages
  12. @c_heliou @xebiconfr #xebiconfr 28 C1 C2 C3 C1 = 10

    ms C2 = 10 ms C2 = 10 ms C2 = 10 + 10 ms
  13. @c_heliou @xebiconfr #xebiconfr 29 Bus Handler Handler EMS thread pool

    IUM thread pool EMS thread pool IUM thread pool Event loop Commandes Évènements Messages Messages
  14. @c_heliou @xebiconfr #xebiconfr 30 Bus Handler Handler EMS thread pool

    IUM thread pool EMS thread pool IUM thread pool Event loop Commandes Évènements Messages Messages Event loop
  15. @c_heliou @xebiconfr #xebiconfr 31 Bus Handler Handler EMS thread pool

    IUM thread pool EMS thread pool IUM thread pool Event loop Commandes Évènements Messages Messages Event loop Commandes
  16. @c_heliou @xebiconfr #xebiconfr 35 Application Inspiré par J. Chassaing -

    http://thinkbeforecoding.com/post/2014/01/04/Event-Sourcing.-Draw-it Évènement(s) Fonction de
 Décision Commande Fonction 
 d’évolution Event store Action
  17. @c_heliou @xebiconfr #xebiconfr 36 Application Inspiré par J. Chassaing -

    http://thinkbeforecoding.com/post/2014/01/04/Event-Sourcing.-Draw-it Évènement(s) Fonction de
 Décision Commande Fonction 
 d’évolution Event store Action
  18. @c_heliou @xebiconfr #xebiconfr 37 Recevoir prix
 {commande} requêteId: 9387 prix:

    100€ Fonction de
 Décision Fonction de
 Décision Prix reçu
 {évènement} requêteId: 9387 prix: 100€ marge: 0,10€ Recevoir prix
 {commande} requêteId: 9387 prix: 100€ Prix reçu
 {évènement} requêteId: 9387 prix: 100€ marge: 0,20€ 12/02/2016 - Marge 0,1% 01/07/2016 - Marge 0,2%
  19. @c_heliou @xebiconfr #xebiconfr 38 Dénommer un évènement n’est pas chose

    Aisée. « Anatomy of domain event » M. Praglowski - http:/ /blog.arkency.com/2016/05/the-anatomy-of-domain-event/
  20. @c_heliou @xebiconfr #xebiconfr 43 Monitoring « Métier » Contrôles basiques


    par client, produit, etc. Suivi temps-réel
 des transactions
  21. @c_heliou @xebiconfr #xebiconfr 45 
Bus d’évènements Multiplus Handler PUSH-API Fonction

    de
 STOCKAGE Fonction 
 D’AGREGATION Event store Évènement QUEUE EMS WEB SOCKET Vue CONSOLE Vue
  22. @c_heliou @xebiconfr #xebiconfr 46 PUSH-API Fonction de
 STOCKAGE Fonction 


    D’AGREGATION Event store WEB SOCKET CONSOLE Évènement
 {transaction #345} Évènements
 {transaction #345} Vue
 {transaction #345} Vue
 {transaction #345}
  23. @c_heliou @xebiconfr #xebiconfr 47 Fonction 
 D’AGREGATION Exécution
 Demandée {transaction

    #345, idSéquence = 1} Exécution
 Acceptée {transaction #345, idSéquence = 2} Fonction 
 D’AGREGATION Vue {transaction #345, 
 statut = TERMINÉE} Vue {transaction #345, 
 statut = EN COURS}
  24. @c_heliou @xebiconfr #xebiconfr 48 Fonction 
 D’AGREGATION Exécution
 Demandée {transaction

    #345, idSéquence = 1} Exécution
 Acceptée {transaction #345, idSéquence = 2} Fonction 
 D’AGREGATION Vue {transaction #345, 
 statut = TERMINÉE} Vue {transaction #345, 
 statut = EN COURS} Fonction 
 D’AGREGATION Exécution
 Acceptée {transaction #345, idSéquence = 2} Vue {transaction #345, 
 statut = TERMINÉE}
  25. @c_heliou @xebiconfr #xebiconfr 51 Poser la 1ère pierre, à l’édifice

    CQRS ! Évènements d’intérêt Évènements 
 en mémoire
  26. @c_heliou @xebiconfr #xebiconfr 53 Ressources ๏Xebicon 15’ - CQRS +

    Event Sourcing: en direct ! ๏Back Day 15’ - Explorer les principes de l’event sourcing ๏Thinkbe4coding #Eventsourcing ๏KATA MixteR - https://github.com/devlyon/mixter - Kata explorant les principes de l’Event Sourcing/CQRS. - https://www.youtube.com/watch?v=QGGZs0KqxZw - Live coding présentant les principes de l’Event Sourcing/CQRS. - http://thinkbeforecoding.com/tag/Event%20Sourcing - L’un des auteurs français à suivre sur le sujet Event Sourcing/CQRS. - http://www.xebia.tv/vod?videoId=S8566fyZHp0 - Présentation plus large du projet Multiplus (DDD, BDD, Architecture hexagonale).