integrating bounded contexts tips - dutch php 2016
TRANSCRIPT
![Page 1: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/1.jpg)
INTEGRATING BCPHP DUTCH 2016 #DPC16
![Page 2: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/2.jpg)
@BUENOSVINOS /GOODWINES/
![Page 3: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/3.jpg)
![Page 4: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/4.jpg)
TEXT
![Page 5: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/5.jpg)
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
![Page 6: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/6.jpg)
START
![Page 7: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/7.jpg)
E-COMMERCE
FRAUD
GAMIFICATION
![Page 8: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/8.jpg)
SYNC / ASYNC REST / MESSAGING
![Page 9: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/9.jpg)
TIPS WHEN DEALING WITH DOMAIN EVENTS
![Page 10: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/10.jpg)
DDD ARCHITECTURAL STYLES TRIP
SPAGUETTI
FRAMEWORK
HEXAGONAL
HEXAGONAL + CQRS
CQRS + ES
![Page 11: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/11.jpg)
START FIRING DOMAIN EVENTS NOW
TIP #1
![Page 12: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/12.jpg)
DOMAIN EVENTS ARE THING THAT HAPPEN IN OUR DOMAIN THAT DOMAIN EXPERTS CARE ABOUT
Vaughn Vernon
DEFINITION
![Page 13: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/13.jpg)
DOMAIN EVENT INTERFACE
![Page 14: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/14.jpg)
LOG IN ATTEMPTED DOMAIN EVENT
![Page 15: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/15.jpg)
PUBLISHING DOMAIN EVENTS
![Page 16: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/16.jpg)
OUR DOMAIN EVENT PUBLISHER
![Page 17: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/17.jpg)
DO SOMETHING SIMPLE WITH THE EVENTS
TIP #2
![Page 18: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/18.jpg)
DOMAIN EVENT SUBSCRIBER INTERFACE
![Page 19: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/19.jpg)
LOG DOMAIN EVENTS INTO ELASTICSEARCH WITH MONOLOG
![Page 20: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/20.jpg)
REGISTER YOUR NEW LISTENER/SUBSCRIBER
![Page 21: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/21.jpg)
![Page 22: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/22.jpg)
![Page 23: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/23.jpg)
PERSIST ALL YOUR DOMAIN EVENTS IN YOUR MAIN STORAGE (DB)TIP #3
![Page 24: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/24.jpg)
…WHEN A NEW APPLICATION ARRIVES
YOU CAN REPLAY ALL THOSE EVENTS AGAINST THE NEW APPLICATION TO LOADED WITH ALL THE INFO…
![Page 25: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/25.jpg)
SUBSCRIBER TO PERSIST ALL DOMAIN EVENTS
![Page 26: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/26.jpg)
LISTENER TO PERSIST ALL DOMAIN EVENTS
![Page 27: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/27.jpg)
EVENT STORE BASED IN DOCTRINE
![Page 28: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/28.jpg)
EVENTS IN THE DATABASE
![Page 29: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/29.jpg)
PERSIST DOMAIN EVENTS IN THE SAME TX AS DOMAIN CHANGESTIP #4
![Page 30: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/30.jpg)
A USER CHANGES HIS EMAILEMAILWASUPDATED
![Page 31: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/31.jpg)
POSSIBLE SCENARIOS
Not notifying about something that happened :(
Notifying about something that do NOT happened :((
![Page 32: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/32.jpg)
CHANGES TO YOUR DOMAIN AND DOMAIN EVENTS SUCCESS OR FAIL AT THE SAME TIME
TOGETHER
![Page 33: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/33.jpg)
PROVIDE A REST API FOR YOUR DOMAIN EVENTS
TIP #5
![Page 34: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/34.jpg)
…IF IT LOOSES A DOMAIN EVENT
ANOTHER APP CAN SYNC ITS STATUS WITH YOUR EVENTS API
![Page 35: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/35.jpg)
API EVENTS ENDPOINT
![Page 36: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/36.jpg)
API EVENTS ENDPOINT RESULT
![Page 37: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/37.jpg)
KEEP TRACK OF LAST PUBLISHED DOMAIN EVENT
TIP #6
![Page 38: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/38.jpg)
PUBLISHING EVENTS
![Page 39: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/39.jpg)
SPREADING EVENTS
![Page 40: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/40.jpg)
EVENT STORE AND MESSAGE TRACKER
![Page 41: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/41.jpg)
![Page 42: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/42.jpg)
![Page 43: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/43.jpg)
![Page 44: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/44.jpg)
![Page 45: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/45.jpg)
USE SUPERVISORD TO CONSUME BATCH OF LIMITED DOMAIN EVENTSTIP #7
![Page 46: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/46.jpg)
CONSUMING DOMAIN EVENTS
![Page 47: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/47.jpg)
TEXT
![Page 48: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/48.jpg)
USE SUPERVISOR TO FIRE WORKERS AND KEEP THEM RUNNING
![Page 49: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/49.jpg)
USE SUPERVISOR TO FIRE WORKERS AND KEEP THEM RUNNING
![Page 50: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/50.jpg)
USE TACTICIAN OR OTHER COMMAND BUSES
TIP #8
![Page 51: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/51.jpg)
FROM MESSAGE TO AN COMMAND HANDLER
![Page 52: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/52.jpg)
IF USING SYMFONY PHP-AMQPLIB/RABBITMQ-BUNDLE AND LEAGUE/TACTICIAN-BUNDLE
![Page 53: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/53.jpg)
PROTECT YOURSELF FROM DUPLICATE MESSAGES WITH IDEMPOTENCETIP #9
![Page 54: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/54.jpg)
TEXT
![Page 55: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/55.jpg)
TREAT YOUR DOMAIN EVENTS AS YOUR REST API
TIP #10
![Page 56: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/56.jpg)
DOCUMENT YOUR DOMAIN EVENTS AS YOU WOULD DO WITH YOUR REST API
![Page 57: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/57.jpg)
USE SAMI, FOR EXAMPLE
![Page 58: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/58.jpg)
VERSION YOUR DOMAIN EVENTS
![Page 59: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/59.jpg)
WRAP-UP
![Page 60: Integrating Bounded Contexts Tips - Dutch PHP 2016](https://reader031.vdocument.in/reader031/viewer/2022021502/587f3dad1a28ab43318b5039/html5/thumbnails/60.jpg)
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