CommandMessage

Represents a complete command message that encapsulates a command to be executed against an aggregate in the Wow framework.

This interface combines multiple concerns for command handling in a domain-driven design (DDD) context:

Command messages are the primary mechanism for initiating state changes in aggregates, supporting both creation and modification operations with proper versioning and idempotency guarantees.

Parameters

C

The type of the command payload, which contains the specific data for the operation

See also

for command uniqueness

for aggregate targeting

for message structure

Example usage:

data class CreateOrderCommand(
val customerId: String,
val items: List<OrderItem>
) : CommandMessage<CreateOrderCommand> {
// Implement required properties...
}

Properties

Link copied to clipboard
abstract override val aggregateId: AggregateId

The target aggregate identifier for this command.

Link copied to clipboard
abstract val aggregateName: String

The name of the aggregate.

Link copied to clipboard
abstract val aggregateVersion: Int?

The expected version of the target aggregate for optimistic concurrency control.

Link copied to clipboard
abstract val allowCreate: Boolean

Indicates whether this command permits the creation of a new aggregate if one doesn't exist.

Link copied to clipboard
abstract val body: C

The typed payload of the message.

Link copied to clipboard
open override val commandId: String

Unique identifier for this command instance, delegated from the message ID.

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 val id: String

Represents a unique identifier for the implementing entity.

Link copied to clipboard
abstract val isCreate: Boolean

Indicates whether this command is intended to create a new aggregate instance.

Link copied to clipboard

Indicates whether this message is in read-only mode.

Link copied to clipboard
abstract val isVoid: Boolean

Indicates whether this command is a void command that doesn't expect a response.

Link copied to clipboard
abstract val name: String

The name of the entity.

Link copied to clipboard
abstract val ownerId: String

The unique identifier of the resource owner.

Link copied to clipboard
abstract val requestId: String

A unique identifier for this request instance.

Functions

Link copied to clipboard
abstract fun copy(): CommandMessage<C>

Creates and returns a copy of the current object.

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>): CommandMessage<C>

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): CommandMessage<C>

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

Link copied to clipboard

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