Inside the model
Events make important business transitions explicit and memorable.
A domain event represents something meaningful that happened in the domain: an order was placed, a payment was authorized, a shipment was delayed. Domain events are not just technical notifications. They help the model express important transitions and often support integration across contexts.
Order placement may trigger downstream work in payments, fulfillment, notifications, and analytics. Even inside one context, naming that event can clarify the model. Across contexts, it often becomes a clean integration point.
Domain events are useful because they turn important business transitions into explicit concepts. That helps both internally, by clarifying model meaning, and externally, by creating stable signals other parts of the system can react to.
Not every internal change deserves an event. The best domain events are meaningful in business language and important enough that the system or people care they happened.
Events make important business transitions explicit and memorable.
Events often support eventual consistency or integration with other contexts.
Event names should sound like domain occurrences, not technical callbacks.
OrderPlaced. Weak event: AfterSaveTriggered. The difference is whether the name reflects business meaning or implementation mechanics.
package org.javaomnibus.ecommerce.domain;
import java.util.ArrayList;
import java.util.List;
public final class Order {
private final List<Object> domainEvents = new ArrayList<>();
public static Order place(OrderId id) {
Order order = new Order();
order.domainEvents.add(new OrderPlaced(id.value()));
return order;
}
public List<Object> domainEvents() {
return List.copyOf(domainEvents);
}
}