DefaultCommandGateway

class DefaultCommandGateway(commandWaitEndpoint: CommandWaitEndpoint, commandBus: CommandBus, validator: Validator, requestIdChecker: RequestIdChecker, waitCoordinator: WaitCoordinator, commandWaitNotifier: CommandWaitNotifier) : CommandGateway, CommandBus

The command gateway: a facade that puts admission in front of a CommandBus it does not own.

Every send goes through one admission chain (CommandAdmission): validate, check the request ID, and, for a wait, register the wait handle and build the message with its wait headers. The SENT signal is produced in one place (sendAdmitted), after the bus accepted or rejected the message, and handed to whoever waits for it. Every wait is bounded by one deadline implementation (WaitDeadline).

receiver delegates to commandBus. close releases only the gateway's own deadline timer: the bus has its own owner (in Spring, its own bean) and is closed by it.

Parameters

commandWaitEndpoint

The endpoint wait signals for this node are sent to.

commandBus

The underlying command bus the admitted commands are sent through.

validator

The validator for command bodies.

requestIdChecker

Checker for command request ID idempotency.

waitCoordinator

Coordinator for managing wait handles.

commandWaitNotifier

Notifier for the SENT signal of a command that carries an upstream wait plan.

Constructors

Link copied to clipboard
constructor(commandWaitEndpoint: CommandWaitEndpoint, commandBus: CommandBus, validator: Validator, requestIdChecker: RequestIdChecker, waitCoordinator: WaitCoordinator, commandWaitNotifier: CommandWaitNotifier)

Properties

Link copied to clipboard
open override val enforcesCommandWaitTimeout: Boolean = true

Whether this gateway enforces WaitPlan.timeout itself.

Functions

Link copied to clipboard
open override fun close()

Releases the deadline timer; registered deadlines stay alive without retaining a shutdown-waiting thread. The command bus is not closed: the gateway did not create it.

Link copied to clipboard

The one receive entry: a single message source for subscription, with an explicit transport readiness boundary and processing admission (see MessageReceiver).

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

Sends a command through the admission chain. When the message carries the wait plan of an upstream command (a command a saga sends for a waiting chain), its SENT signal, or its admission failure, goes to that plan.

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

Sends a command and waits for the result of the waited stage.

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

Sends a command and completes with the SENT stage result as soon as the command bus accepts it, without registering a wait handle or writing wait headers: no stage after SENT is waited on. Bounded by the default command wait timeout.

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

Sends a command and streams its results as the waited stages report them.