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 OrderCreated

Since

1.0.0

Parameters

SOURCE

The concrete type of this event message, used for self-referential typing

T

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

Link copied to clipboard
abstract val aggregateId: AggregateId

The aggregate ID used to uniquely identify an aggregate instance.

Link copied to clipboard
abstract val aggregateName: String

The name of the aggregate.

Link copied to clipboard
abstract val body: T

The typed payload of the message.

Link copied to clipboard
abstract val commandId: String

A unique identifier for this command instance.

Link copied to clipboard
abstract val contextName: String

The name of the bounded context this entity belongs to.

Link copied to clipboard
abstract override val createTime: Long

The timestamp when this message was created, as a Unix timestamp in milliseconds.

Link copied to clipboard
abstract val header: Header

The header containing metadata about this message.

Link copied to clipboard
abstract override val id: String

Represents a unique identifier for the implementing entity.

Link copied to clipboard

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.

Link copied to clipboard

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.

Link copied to clipboard

Indicates whether this message is in read-only mode.

Link copied to clipboard
abstract val ownerId: String

The unique identifier of the resource owner.

Link copied to clipboard
abstract val spaceId: SpaceId

The namespace string used for data layering under a tenant. This value should be non-null and represent a valid identifier for the data layer. An empty string indicates the default namespace for the tenant.

Link copied to clipboard
abstract val version: Int

The current version number of the entity as an integer. Versions are monotonically increasing and start from 1 for initialized entities. A version of 0 indicates an uninitialized state.

Functions

Link copied to clipboard

Checks if two aggregates belong to the same context and have the same aggregate name.

Link copied to clipboard

Checks if this entity belongs to the same bounded context as another entity.

Link copied to clipboard
open fun withHeader(additionalSource: Map<String, String>): SOURCE

Adds all key-value pairs from the provided map to the message header and returns the message for method chaining.

open fun withHeader(key: String, value: String): SOURCE

Adds a key-value pair to the message header and returns the message for method chaining.

Link copied to clipboard
open fun withReadOnly(): SOURCE

Marks this message as read-only and returns it for method chaining.