Event replay
by Fikri

by Fikri
Introduction
For this project, I have built a simple order management system to learn about event replay and event driven architecture.
What I have done & learnt
From the diagram shown above, when an order comes in through API, an OrderPlaced event has been triggered, and 4 listeners subsequently execute the logic. In each of the handle method in the listener, there is idempotency check to prevent duplicate operations on replay. In the case of failed listener, the event replay can be used to trigger all the listener again. All the logics have been tested with pest in the OrderTest file.
Current project architecture
Source of Truth:
orderstable for Current order stateinventorytable for Current stock levelsemail_logstable for What emails were sentnotificationstable for What notifications exist
Currently domain_events table is being used for audit trail and replay purposes only.
Improvements
- Create more event types instead of just one
OrderPlacedevent (e.g.,OrderShipped,OrderCancelled) - Implement a proper event sourcing architecture where the event store is the single source of truth, rather than the current approach where application state can be obtained by replaying events from the event store