DomainEvent
Represents a domain event published by an aggregate in response to a command.
Domain events capture significant business occurrences that have happened within an aggregate. They are immutable facts about past actions and serve as the primary mechanism for communicating state changes to other parts of the system.
Domain events follow declarative design principles (idempotent, similar to Kubernetes apply or Docker image layers). During event sourcing, aggregates should simply apply domain events as overlay layers without complex logic or conditional checks, eliminating the need for explicit sourcing functions.
Key characteristics:
Immutable: Events represent facts that cannot be changed
Named: Each event has a specific business meaning
Versioned: Events carry version information for compatibility
Sequenced: Events maintain order within an aggregate's lifecycle
Author
ahoo wang
Parameters
The type of the event body payload
See also
for base messaging capabilities
for aggregate identification
for versioning information
Properties
The unique identifier of the aggregate that published this domain event.
The name of the aggregate.
The name of the bounded context this entity belongs to.
The timestamp when this message was created, as a Unix timestamp in milliseconds.
A computed property that indicates whether the entity has been initialized. Returns true if the version is greater than UNINITIALIZED_VERSION. This property is ignored during JSON serialization.
A computed property that indicates whether the entity is at its initial version. Returns true if the version equals INITIAL_VERSION. This property is ignored during JSON serialization.
Indicates whether this message is in read-only mode.
Functions
Checks if two aggregates belong to the same context and have the same aggregate name.
Checks if this entity belongs to the same bounded context as another entity.
Adds all key-value pairs from the provided map to the message header and returns the message for method chaining.
Adds a key-value pair to the message header and returns the message for method chaining.
Marks this message as read-only and returns it for method chaining.