CommandMessage

Represents a command message that can be sent to an aggregate. This interface extends several other interfaces to provide a comprehensive set of properties and methods for handling commands within a domain-driven design (DDD) context.

The CommandMessage interface ensures that each command has a unique identifier, is associated with an aggregate, and can be copied. It also provides properties to manage the state and behavior of the command, such as whether it is a create command or if it allows the creation of a new aggregate.

Parameters

C

the type of the command payload

Properties

Link copied to clipboard
abstract override val aggregateId: AggregateId

Represents the unique identifier of the aggregate to which this command message is directed. This property is essential for identifying the specific aggregate that the command should be applied to, ensuring that commands are correctly routed and processed within the system.

Link copied to clipboard
abstract val aggregateName: String

aggregate name.

Link copied to clipboard
abstract val aggregateVersion: Int?

Represents the version of the aggregate. This value is used to ensure that commands are applied to the correct version of an aggregate, which is essential for maintaining consistency and preventing conflicts in concurrent environments. A null value indicates that the version is not specified or relevant.

Link copied to clipboard
abstract val allowCreate: Boolean

Indicates whether the creation of a new aggregate is allowed by this command. This property is useful in scenarios where certain commands should only be applied to existing aggregates or when there are specific conditions under which an aggregate can be created.

Link copied to clipboard
abstract val body: C
Link copied to clipboard
open override val commandId: String

Represents a unique identifier for a command. This identifier is crucial for ensuring that each command can be uniquely identified, which is particularly useful in scenarios where idempotency of commands needs to be guaranteed or when tracking and correlating commands across system boundaries.

Link copied to clipboard
abstract val contextName: String
Link copied to clipboard
abstract val createTime: Long
Link copied to clipboard
abstract val header: Header
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 the command is intended for creating a new aggregate. This property is crucial in determining the nature of the command, specifically if it's meant to initialize a new aggregate instance.

Link copied to clipboard
Link copied to clipboard
abstract val isVoid: Boolean

Indicates whether the command message is a void command. A void command does not expect a return value and is typically used for operations that do not require a response.

Link copied to clipboard
abstract val name: String
Link copied to clipboard
abstract val ownerId: String

资源拥有者Id

Link copied to clipboard
abstract val requestId: String

Represents a unique identifier for a request. This identifier is crucial for ensuring that each request can be uniquely identified, which is particularly useful in scenarios where idempotency of requests needs to be guaranteed or when tracking and correlating requests across system boundaries.

Functions

Link copied to clipboard
abstract fun copy(): CommandMessage<C>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun withHeader(additionalSource: Map<String, String>): CommandMessage<C>

合并 header 并返回一个新的 Message.

open fun withHeader(key: String, value: String): CommandMessage<C>
Link copied to clipboard