SimpleDomainEvent

data class SimpleDomainEvent<T : Any>(val id: String = generateGlobalId(), val header: Header = DefaultHeader.empty(), val body: T, val aggregateId: AggregateId, val ownerId: String = OwnerId.DEFAULT_OWNER_ID, val version: Int, val sequence: Int = DEFAULT_EVENT_SEQUENCE, val revision: String = DEFAULT_REVISION, val commandId: String, val name: String = body.javaClass.toName(), val isLast: Boolean = true, val createTime: Long = System.currentTimeMillis()) : DomainEvent<T> , NamedAggregate

Simple implementation of DomainEvent.

This data class provides a concrete implementation of the DomainEvent interface, representing a domain event with all required metadata and payload information.

Parameters

T

The type of the event body

See also

Constructors

Link copied to clipboard
constructor(id: String = generateGlobalId(), header: Header = DefaultHeader.empty(), body: T, aggregateId: AggregateId, ownerId: String = OwnerId.DEFAULT_OWNER_ID, version: Int, sequence: Int = DEFAULT_EVENT_SEQUENCE, revision: String = DEFAULT_REVISION, commandId: String, name: String = body.javaClass.toName(), isLast: Boolean = true, createTime: Long = System.currentTimeMillis())

Creates a new SimpleDomainEvent with the specified properties

Properties

Link copied to clipboard
open override val aggregateId: AggregateId

The aggregate ID this event belongs to

Link copied to clipboard
open override val aggregateName: String
Link copied to clipboard
open override val body: T

The event payload data

Link copied to clipboard
open override val commandId: String

The ID of the command that triggered this event

Link copied to clipboard
open override val contextName: String
Link copied to clipboard
open override val createTime: Long

The timestamp when the event was created (default: current time)

Link copied to clipboard
open override val header: Header

The message header containing metadata (default: empty header)

Link copied to clipboard
open override val id: String

The unique identifier of this event (default: generated global ID)

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override val isLast: Boolean

Whether this is the last event in the stream (default: true)

Link copied to clipboard
Link copied to clipboard
open override val name: String

The event name (default: derived from body class name)

Link copied to clipboard
open override val ownerId: String

The owner identifier (default: DEFAULT_OWNER_ID)

Link copied to clipboard
open override val revision: String

The event schema revision (default: DEFAULT_REVISION)

Link copied to clipboard
open override val sequence: Int

The sequence number within the event stream (default: DEFAULT_EVENT_SEQUENCE)

Link copied to clipboard
open override val version: Int

The aggregate version when this event was created

Functions

Link copied to clipboard
fun NamedAggregate.aggregateId(id: String = generateId(), tenantId: String = TenantId.DEFAULT_TENANT_ID): DefaultAggregateId

Creates an AggregateId for this NamedAggregate with the specified parameters.

Link copied to clipboard

Finds the aggregate type class associated with this named aggregate.

Link copied to clipboard

Converts this NamedAggregate to its corresponding AggregateMetadata.

Link copied to clipboard

Generates a unique ID string for this NamedAggregate.

Link copied to clipboard
fun NamedBoundedContext.getContextAlias(boundedContext: BoundedContext? = MetadataSearcher.metadata.contexts[contextName]): String
Link copied to clipboard

Gets the context alias prefix for this bounded context.

Link copied to clipboard

Checks if the named aggregate is available locally at runtime.

Link copied to clipboard
open override fun isSameAggregateName(other: NamedAggregate): Boolean
Link copied to clipboard
Link copied to clipboard
fun Message<*, *>.match(function: FunctionInfo): Boolean

Checks if this message matches the given function for compensation purposes.

Link copied to clipboard

Finds the aggregate type class associated with this named aggregate, throwing an exception if not found.

Link copied to clipboard

Extension function to convert a NamedAggregate to an EventNamedAggregate.

Link copied to clipboard

Extension function to convert a domain event with error info to a DomainEventException.

Link copied to clipboard
fun AggregateIdCapable.toGroupKey(parallelism: Int = DEFAULT_PARALLELISM): Int

Computes a grouping key for parallel processing based on the aggregate ID.

Link copied to clipboard

Converts this NamedAggregate to its string representation.

Link copied to clipboard

Converts this NamedAggregate to a string representation using the context alias.

Link copied to clipboard
open fun withHeader(additionalSource: Map<String, String>): DomainEvent<T>
open fun withHeader(key: String, value: String): DomainEvent<T>
Link copied to clipboard