AggregateCommandDispatcher

class AggregateCommandDispatcher<C : Any, S : Any>(val name: String = "-", val aggregateMetadata: AggregateMetadata<C, S>, val messageFlux: Flux<ServerCommandExchange<*>>, val parallelism: Int = MessageParallelism.DEFAULT_PARALLELISM, commandHandler: CommandHandler, val scheduler: Scheduler, messageReadiness: Mono<Void> = Mono.empty(), processingAdmission: () -> Unit = {}, processingQuiescence: () -> Unit = {}, metrics: WowMetrics = WowMetrics.NONE) : AggregateDispatcher<ServerCommandExchange<*>>

Aggregate command dispatcher grouped by named aggregate.

This dispatcher manages command processing for a specific named aggregate, ensuring proper parallelism and thread affinity. Each aggregate ID is bound to one worker thread, but one worker can handle multiple aggregate IDs, providing efficient resource utilization.

Key characteristics:

  • One AggregateId binds to one Worker (Thread)

  • One Worker can be bound by multiple aggregateIds

  • Workers have aggregate ID affinity for consistent processing

Parameters

name

The name of this dispatcher.

messageFlux

The flux of command exchanges to process.

parallelism

The level of parallelism for message processing.

commandHandler

The command handler for processing commands.

scheduler

The scheduler for handling messages.

messageReadiness

Completion of asynchronous message-source setup when this dispatcher is registered directly with a runtime.

processingAdmission

Explicit transport-processing gate opened by start.

processingQuiescence

Logical transport gate closed by quiesce.

metrics

Instance-scoped metrics recorder for dispatcher operations.

Type Parameters

C

The type of the command aggregate root.

S

The type of the state aggregate.

Constructors

Link copied to clipboard
constructor(name: String = "-", aggregateMetadata: AggregateMetadata<C, S>, messageFlux: Flux<ServerCommandExchange<*>>, parallelism: Int = MessageParallelism.DEFAULT_PARALLELISM, commandHandler: CommandHandler, scheduler: Scheduler, messageReadiness: Mono<Void> = Mono.empty(), processingAdmission: () -> Unit = {}, processingQuiescence: () -> Unit = {}, metrics: WowMetrics = WowMetrics.NONE)

Properties

Link copied to clipboard

The metadata for the aggregate being dispatched.

Link copied to clipboard
open override val messageFlux: Flux<ServerCommandExchange<*>>
Link copied to clipboard
open override val name: String
Link copied to clipboard
open override val namedAggregate: NamedAggregate
Link copied to clipboard
open override val parallelism: Int
Link copied to clipboard
open override val scheduler: Scheduler

Functions

Link copied to clipboard
open override fun handleExchange(exchange: ServerCommandExchange<*>): Mono<Void>

Handles a single command exchange by setting up the processing context and delegating to the command handler.

Link copied to clipboard
open override fun ServerCommandExchange<*>.toGroupKey(): Int

Generates a group key for the command exchange to ensure proper parallelism and ordering.