DefaultCommandGateway

class DefaultCommandGateway(commandWaitEndpoint: CommandWaitEndpoint, commandBus: CommandBus, validator: Validator, idempotencyCheckerProvider: AggregateIdempotencyCheckerProvider, waitStrategyRegistrar: WaitStrategyRegistrar, commandWaitNotifier: CommandWaitNotifier) : CommandGateway, CommandBus

Default implementation of the CommandGateway interface. This gateway provides comprehensive command handling including validation, idempotency checking, and various sending strategies with optional waiting.

Constructors

Link copied to clipboard
constructor(commandWaitEndpoint: CommandWaitEndpoint, commandBus: CommandBus, validator: Validator, idempotencyCheckerProvider: AggregateIdempotencyCheckerProvider, waitStrategyRegistrar: WaitStrategyRegistrar, commandWaitNotifier: CommandWaitNotifier)

Properties

Link copied to clipboard
open override val topicKind: TopicKind

The topic kind for command messages, always returns TopicKind.COMMAND

Functions

Link copied to clipboard
open override fun close()

Closes the message bus and releases any resources. Default implementation does nothing.

Link copied to clipboard
open override fun receive(namedAggregates: Set<NamedAggregate>): Flux<ServerCommandExchange<*>>

Receives messages for the specified named aggregates.

Link copied to clipboard
open override fun send(message: CommandMessage<*>): Mono<Void>

Sends a command message through the command bus after performing validation and idempotency checks. Notifies wait strategies if configured in the message header.

open override fun <C : Any> send(command: CommandMessage<C>, waitStrategy: WaitStrategy): Mono<out ClientCommandExchange<C>>

Sends a command with a specific wait strategy and returns a command exchange for tracking. This method handles wait strategy registration, propagation, and cleanup.

Link copied to clipboard
open override fun <C : Any> sendAndWait(command: CommandMessage<C>, waitStrategy: WaitStrategy): Mono<CommandResult>

Sends a command and waits for the final result. Throws CommandResultException if the command execution fails.

Link copied to clipboard

Sends a command and waits until it is fully processed by the aggregate.

Link copied to clipboard
open fun <C : Any> sendAndWaitForSent(command: CommandMessage<C>): Mono<CommandResult>

Sends a command and waits until it is successfully sent to the command bus.

Link copied to clipboard
open fun <C : Any> sendAndWaitForSnapshot(command: CommandMessage<C>): Mono<CommandResult>

Sends a command and waits until the aggregate state is snapshotted.

Link copied to clipboard
open override fun <C : Any> sendAndWaitStream(command: CommandMessage<C>, waitStrategy: WaitStrategy): Flux<CommandResult>

Sends a command and returns a stream of command results as they become available. This method allows monitoring the progress of command execution in real-time.