toCommandMessage
Converts any object to a CommandMessage using reflection and metadata.
This extension function analyzes the command object's class to extract metadata and construct a properly configured CommandMessage. It uses command metadata to determine aggregate targeting, property getters, and command characteristics.
Return
a properly configured CommandMessage
Parameters
the type of the command
unique identifier for the command message (auto-generated if not provided)
request identifier for tracking (defaults to id)
target aggregate instance ID (optional, extracted from command if available)
tenant identifier (optional, extracted from command if available)
owner identifier (optional, extracted from command if available)
expected aggregate version (optional, extracted from command if available)
named aggregate information (optional, extracted from command if available)
message headers (default empty)
creation timestamp (default current time)
upstream domain event (optional)
whether owner ID should match aggregate ID
See also
Throws
if no named aggregate can be determined
Converts a CommandBuilder to a CommandMessage.
This extension function takes all the properties configured in the CommandBuilder and creates a corresponding CommandMessage using the same logic as the command object's toCommandMessage method.
Return
a CommandMessage with all builder properties applied
Parameters
the type of the command body