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
the type of the command payload
Properties
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.
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.
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.
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.
The create time of the message, represented as a Unix timestamp in milliseconds.
Indicates whether the message is read-only, based on the state of the header.
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
复制当前对象 该方法用于创建并返回当前对象的一个复制品,确保复制品在修改时不会影响到原始对象
检查两个聚合根是否属于同一个上下文并具有相同的聚合根名称。
Adds all entries from the provided map to the message header and returns the message itself for method chaining.
Adds a key-value pair to the message header and returns the message itself for method chaining.
Marks the message as read-only and returns the message itself for method chaining.