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 spaceId: SpaceId = SpaceIdCapable.DEFAULT_SPACE_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

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.

spaceId

Identifier of the space containing the aggregate. Defaults to the default space.

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.

Type Parameters

C

The type of the command body.

Constructors

Link copied to clipboard
constructor(id: String = generateGlobalId(), header: Header = DefaultHeader.empty(), body: C, aggregateId: AggregateId, ownerId: String = OwnerId.DEFAULT_OWNER_ID, spaceId: SpaceId = SpaceIdCapable.DEFAULT_SPACE_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 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 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
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
Link copied to clipboard
open override val spaceId: SpaceId

Functions

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.