CommandMessages

The messages of the command and receipts topics, each an Envelope:

  • Command (EnvelopeKind.COMMAND): id is the command id, type its full type name (ctx.agg.Command), payload its wire form (CommandWire, with replyTo when a saga sent it), transport its wait context, if any. Keyed by the aggregate ref (laneOf: a creation that names no aggregate by its request); its partition is the one the log's partitioner gives that ref among the topic's partitions, which are the target context's log partitions.

  • Receipt (EnvelopeKind.COMMAND_RECEIPT): id is the rejected command's id, the one a reader deduplicates by, type its type, payload the rejection as the saga's @OnRejected handler takes it, {commandId, commandType, ref, error, causation, executionId, operator, scope, headers} (headers the command's request facts that propagate), without the command's body. Keyed by the ref of the commit the saga handled, so the receipts of one saga aggregate keep their order. A success receipt, the same kind and id, carries the commit instead: {commandId, commandType, ref, version, result, causation, executionId, operator, scope, headers}, its result the command's CommandResult at its committed hop, no state.

Bodies and payloads are read and written with the cluster channel's lenient mapper (ClusterCodec): unknown fields are ignored, and numbers keep their exact value.

Functions

Link copied to clipboard
fun command(wire: CommandWire, partition: Int, wait: WaitContext? = null, trace: Map<String, String> = emptyMap()): TopicMessage

The message of wire in partition, carrying wait and the propagation fields of its trace.

Link copied to clipboard

The command envelope holds.

Link copied to clipboard

The commit the success receipt envelope holds.

Link copied to clipboard
fun receipt(committed: CommandReceipt.Committed<*>, trace: Map<String, String> = emptyMap(), wait: WaitContext? = null): TopicMessage

The success receipt of committed: id is the command's id, as a rejection's, and payload {commandId, commandType, ref, version, result, causation, executionId, operator, scope, headers}, without the state, carrying the propagation fields of its trace and, in its transport, the wait of the command it answers past its commit: the rest of the chain, whose next hop is the saga's @OnCommitted handler.

fun receipt(rejected: CommandReceipt.Rejected<*>, trace: Map<String, String> = emptyMap(), wait: WaitContext? = null): TopicMessage

The receipt of rejected, carrying the propagation fields of its trace and the wait of the command it answers past its commit, if any.

Link copied to clipboard
fun receiptOf(envelope: Envelope): Any

What the receipt envelope holds: a CommandReceipt.Committed when its payload carries a result, else a CommandReceipt.Rejected.

Link copied to clipboard

The rejection the receipt envelope holds.