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

Type Parameters

T

The type of the event body payload

See also

for base messaging capabilities

for aggregate identification

for versioning information

Properties

Link copied to clipboard
abstract override val aggregateId: AggregateId

The unique identifier of the aggregate that published this domain event.

Link copied to clipboard
open val isLast: Boolean

Indicates whether this is the last event in the current event stream.

Link copied to clipboard
open override val revision: String

The revision/version of the aggregate when this event was published.

Link copied to clipboard
open val sequence: Int

The sequence number of this event within the aggregate's event stream.