This is an example application using Transactional Outbox Pattern
Application assumptions:
- MongoDb
- Doctrine Mongo ODM
- Command Bus
- No framework
- PHP League components
- Symfony CLI Command component
The change flow:
- The command is executed on command bus
- The command is sent to the handler
- The handler do operations on the domain object
- The domain object changes state and produces events
- The events are dispatched
- The events are intercepted
- The domain object is persisted via Doctrine ODM
- The Doctrine dispatches pre persist event
- The pre persist event is used to add events to the persisted object
- Finally, after the command handler the middleware calls Doctrine flush that stored the data to the database