Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Integrating Bounded Contexts Tips - Dutch PHP 2016

1,615 views

Published on

10 tips to integrate different applications putting more focus into asynchronous communications using Domain Events.

Published in: Software

Integrating Bounded Contexts Tips - Dutch PHP 2016

  1. 1. INTEGRATING BC PHP DUTCH 2016 #DPC16
  2. 2. @BUENOSVINOS /GOODWINES/
  3. 3. TEXT
  4. 4. REAL EXAMPLES WRITTEN IN PHP SHOWCASING DDD ARCHITECTURAL STYLES, TACTICAL DESIGN, AND BOUNDED CONTEXT INTEGRATION foreword by Matthias Noback https://leanpub.com/ddd-in-php
  5. 5. START
  6. 6. E-COMMERCE FRAUD GAMIFICATION
  7. 7. SYNC / ASYNC REST / MESSAGING
  8. 8. TIPS WHEN DEALING WITH DOMAIN EVENTS
  9. 9. DDD ARCHITECTURAL STYLES TRIP SPAGUETTI FRAMEWORK HEXAGONAL HEXAGONAL + CQRS CQRS + ES
  10. 10. START FIRING DOMAIN EVENTS NOW TIP #1
  11. 11. DOMAIN EVENTS ARE THING THAT HAPPEN IN OUR DOMAIN THAT DOMAIN EXPERTS CARE ABOUT Vaughn Vernon DEFINITION
  12. 12. DOMAIN EVENT INTERFACE
  13. 13. LOG IN ATTEMPTED DOMAIN EVENT
  14. 14. PUBLISHING DOMAIN EVENTS
  15. 15. OUR DOMAIN EVENT PUBLISHER
  16. 16. DO SOMETHING SIMPLE WITH THE EVENTS TIP #2
  17. 17. DOMAIN EVENT SUBSCRIBER INTERFACE
  18. 18. LOG DOMAIN EVENTS INTO ELASTICSEARCH WITH MONOLOG
  19. 19. REGISTER YOUR NEW LISTENER/SUBSCRIBER
  20. 20. PERSIST ALL YOUR DOMAIN EVENTS IN YOUR MAIN STORAGE (DB) TIP #3
  21. 21. …WHEN A NEW APPLICATION ARRIVES YOU CAN REPLAY ALL THOSE EVENTS AGAINST THE NEW APPLICATION TO LOADED WITH ALL THE INFO…
  22. 22. SUBSCRIBER TO PERSIST ALL DOMAIN EVENTS
  23. 23. LISTENER TO PERSIST ALL DOMAIN EVENTS
  24. 24. EVENT STORE BASED IN DOCTRINE
  25. 25. EVENTS IN THE DATABASE
  26. 26. PERSIST DOMAIN EVENTS IN THE SAME TX AS DOMAIN CHANGES TIP #4
  27. 27. A USER CHANGES HIS EMAIL EMAILWASUPDATED
  28. 28. POSSIBLE SCENARIOS Not notifying about something that happened :( Notifying about something that do NOT happened :((
  29. 29. CHANGES TO YOUR DOMAIN AND DOMAIN EVENTS SUCCESS OR FAIL AT THE SAME TIME TOGETHER
  30. 30. PROVIDE A REST API FOR YOUR DOMAIN EVENTS TIP #5
  31. 31. …IF IT LOOSES A DOMAIN EVENT ANOTHER APP CAN SYNC ITS STATUS WITH YOUR EVENTS API
  32. 32. API EVENTS ENDPOINT
  33. 33. API EVENTS ENDPOINT RESULT
  34. 34. KEEP TRACK OF LAST PUBLISHED DOMAIN EVENT TIP #6
  35. 35. PUBLISHING EVENTS
  36. 36. SPREADING EVENTS
  37. 37. EVENT STORE AND MESSAGE TRACKER
  38. 38. USE SUPERVISORD TO CONSUME BATCH OF LIMITED DOMAIN EVENTS TIP #7
  39. 39. CONSUMING DOMAIN EVENTS
  40. 40. TEXT
  41. 41. USE SUPERVISOR TO FIRE WORKERS AND KEEP THEM RUNNING
  42. 42. USE SUPERVISOR TO FIRE WORKERS AND KEEP THEM RUNNING
  43. 43. USE TACTICIAN OR OTHER COMMAND BUSES TIP #8
  44. 44. FROM MESSAGE TO AN COMMAND HANDLER
  45. 45. IF USING SYMFONY PHP-AMQPLIB/RABBITMQ-BUNDLE AND LEAGUE/TACTICIAN-BUNDLE
  46. 46. PROTECT YOURSELF FROM DUPLICATE MESSAGES WITH IDEMPOTENCE TIP #9
  47. 47. TEXT
  48. 48. TREAT YOUR DOMAIN EVENTS AS YOUR REST API TIP #10
  49. 49. DOCUMENT YOUR DOMAIN EVENTS AS YOU WOULD DO WITH YOUR REST API
  50. 50. USE SAMI, FOR EXAMPLE
  51. 51. VERSION YOUR DOMAIN EVENTS
  52. 52. WRAP-UP
  53. 53. WRAP-UP INTEGRATING BOUNDED CONTEXT TIPS ▸ Integration strategies: Messaging (Async) over REST (Sync) ▸ Start firing Domain Events from deeper in your Model as possible ▸ Add simple listeners in your bootstrapping (Elastic + Kibana) ▸ Persist Domain Events into your main storage in the same Tx as Domain changes ▸ Provide an API endpoint for your Domain Events so other apps can get in sync ▸ Publish your Domain events to a Messaging System (RabbitMQ) and keep track of the last messages sent ▸ Protect yourself with Idem Potent operations
  54. 54. THANKS! @BUENOSVINOS HTTPS://JOIND.IN/TALK/612BA

×