Grokking Microservices Design Patterns
Vote
0% completed
Event Sourcing: An Example
The earlier lessons described event sourcing in words. This lesson shows it in working Java code. We build the bank account example in three small blocks: the events, the aggregate, and the command flow.
The Events
Each event is a small immutable record of one fact. In Java, a record is a short class that only stores data. That makes records a natural fit for events.
We also declare a shared Event interface. A sealed interface lists every type that is allowed to implement it. This example needs Java 21, because it also uses pattern matching in a switch
.....
.....
.....
Like the course? Get enrolled and start learning!