Domain events
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
record that something happened in the domain.
Planned topics
- A domain event is a fact in the past tense:
OrderPlaced,OrderCancelled. - The aggregate raises events as part of a state change; other code reacts.
- Events are immutable and carry the aggregate ID and time.
- Within a service they decouple side effects; to leave the service they become integration events (MID-026, MID-029).
- Do not publish before the state change is saved.
Draft outline details
Demonstration
Order.place() adds new OrderPlaced(id, Instant.now()) to an internal list that the application service publishes after saving.
Check your understanding
Why past tense?
Show answer
An event states a fact that already happened.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.