SimpleCommandMessage

data class SimpleCommandMessage<C : Any>(val id: String = generateGlobalId(), val header: Header = DefaultHeader.empty(), val body: C, val aggregateId: AggregateId, val ownerId: String = OwnerId.DEFAULT_OWNER_ID, val requestId: String = id, val aggregateVersion: Int? = null, val name: String = body.javaClass.toName(), val isCreate: Boolean = false, val allowCreate: Boolean = false, val isVoid: Boolean = false, val createTime: Long = System.currentTimeMillis()) : CommandMessage<C> , NamedAggregate

Simple implementation of CommandMessage with default values for most properties. This class provides a convenient way to create command messages with sensible defaults.

Parameters

C

The type of the command body.

id

Unique identifier for the command message. Defaults to a generated global ID.

header

Message header containing metadata. Defaults to an empty header.

body

The actual command payload.

aggregateId

Identifier of the aggregate this command targets.

ownerId

Identifier of the owner/user initiating the command. Defaults to default owner.

requestId

Identifier for request deduplication. Defaults to the message ID.

aggregateVersion

Expected version of the aggregate for optimistic concurrency. Null means no version check.

name

Human-readable name of the command. Defaults to the simple class name of the body.

isCreate

Whether this command creates a new aggregate instance.

allowCreate

Whether creation is allowed if the aggregate doesn't exist.

isVoid

Whether this is a void command that doesn't produce events.

createTime

Timestamp when the command was created. Defaults to current time.

Constructors

Link copied to clipboard
constructor(id: String = generateGlobalId(), header: Header = DefaultHeader.empty(), body: C, aggregateId: AggregateId, ownerId: String = OwnerId.DEFAULT_OWNER_ID, requestId: String = id, aggregateVersion: Int? = null, name: String = body.javaClass.toName(), isCreate: Boolean = false, allowCreate: Boolean = false, isVoid: Boolean = false, createTime: Long = System.currentTimeMillis())

Properties

Link copied to clipboard
open override val aggregateId: AggregateId
Link copied to clipboard
open override val aggregateName: String
Link copied to clipboard
open override val aggregateVersion: Int?
Link copied to clipboard
open override val allowCreate: Boolean
Link copied to clipboard
open override val body: C
Link copied to clipboard
open override val commandId: String
Link copied to clipboard
open override val contextName: String
Link copied to clipboard
open override val createTime: Long
Link copied to clipboard
open override val header: Header
Link copied to clipboard
open override val id: String
Link copied to clipboard
open override val isCreate: Boolean
Link copied to clipboard
Link copied to clipboard
open override val isVoid: Boolean
Link copied to clipboard
open override val name: String
Link copied to clipboard
open override val ownerId: String
Link copied to clipboard
open override val requestId: String

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
fun CommandMessage<*>.commandSentSignal(waitCommandId: String, error: Throwable? = null): WaitSignal
Link copied to clipboard
open override fun copy(): CommandMessage<C>

Creates a copy of this command message with a deep copy of the header. This ensures header modifications don't affect the original message.

Link copied to clipboard

Ensures the command message has a trace ID, using its own ID if none exists.

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
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>): CommandMessage<C>
open fun withHeader(key: String, value: String): CommandMessage<C>
Link copied to clipboard