EventMessage
Represents a domain event message within the Wow framework's event sourcing architecture.
This interface serves as the base marker for all domain events, providing a comprehensive set of identifiers and metadata necessary for event processing, correlation, and tracking in distributed systems. It combines multiple capability interfaces to provide a complete event representation.
The EventMessage is the fundamental unit of state change in the event sourcing paradigm. Each event represents a fact that has happened in the domain, and together they form an immutable sequence of state changes for aggregates.
Inherited Capabilities
The interface extends multiple capability interfaces, each serving a specific purpose:
NamedBoundedContextMessage: Identifies the bounded context that produced this event
CommandId: Correlates the event with the command that triggered it
NamedAggregate: Identifies the aggregate type that this event belongs to
Version: Tracks the aggregate's version after applying this event
AggregateIdCapable: Identifies the specific aggregate instance
OwnerId: Tracks the owner who created/modified this event
SpaceIdCapable: Supports namespace-based data layering within tenant context
Usage Example
data class OrderCreatedEvent(
override val aggregateId: String,
override val aggregateVersion: Int,
override val commandId: String,
override val tenantId: String,
override val ownerId: String,
override val spaceId: String,
val orderId: String,
val customerId: String,
val totalAmount: BigDecimal
) : EventMessage<OrderCreatedEvent, OrderCreated>
interface OrderCreatedSince
1.0.0
Parameters
The concrete type of this event message, used for self-referential typing
The event type marker, typically an empty interface for type-safe event handling
See also
for concrete event implementation
for the command counterpart
Inheritors
Properties
The aggregate ID used to uniquely identify an aggregate instance.
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.