CompositeEventDispatcher

open class CompositeEventDispatcher(val name: String, parallelism: Int = MessageParallelism.DEFAULT_PARALLELISM, domainEventBus: DomainEventBus, stateEventBus: StateEventBus, functionRegistrar: MessageFunctionRegistrar<MessageFunction<Any, DomainEventExchange<*>, Mono<*>>>, eventHandler: EventHandler, schedulerSupplier: AggregateSchedulerSupplier) : MessageDispatcher

A composite event dispatcher that combines event stream and state event dispatchers to handle domain events and state events efficiently.

This class implements the MessageDispatcher interface and delegates event processing to two specialized dispatchers:

It provides a unified way to start and stop both dispatchers, ensuring proper lifecycle management and parallelism control.

Example usage:

val dispatcher = CompositeEventDispatcher(
name = "MyApp.DomainEventDispatcher",
parallelism = 4,
domainEventBus = myDomainEventBus,
stateEventBus = myStateEventBus,
functionRegistrar = myFunctionRegistrar,
eventHandler = myEventHandler,
schedulerSupplier = mySchedulerSupplier
)
dispatcher.start()
// ... application logic ...
dispatcher.stopGracefully().block()

Parameters

name

The name of this dispatcher, typically formatted as applicationName.DomainEventDispatcher.

parallelism

The level of parallelism for processing events. Defaults to MessageParallelism.DEFAULT_PARALLELISM.

domainEventBus

The domain event bus for publishing and subscribing to domain events.

stateEventBus

The state event bus for handling state-related events.

functionRegistrar

The registrar for domain event handler functions.

eventHandler

The event handler for processing domain events.

schedulerSupplier

Supplier for creating schedulers for aggregate processing. Defaults to a default implementation.

See also

Inheritors

Constructors

Link copied to clipboard
constructor(name: String, parallelism: Int = MessageParallelism.DEFAULT_PARALLELISM, domainEventBus: DomainEventBus, stateEventBus: StateEventBus, functionRegistrar: MessageFunctionRegistrar<MessageFunction<Any, DomainEventExchange<*>, Mono<*>>>, eventHandler: EventHandler, schedulerSupplier: AggregateSchedulerSupplier)

Properties

Link copied to clipboard
open override val name: String

The name of this dispatcher, typically formatted as applicationName.DomainEventDispatcher.

Functions

Link copied to clipboard
open override fun close()

Closes this resource by performing a graceful shutdown.

Link copied to clipboard
open override fun start()

Starts the composite event dispatcher by initializing and starting both the event stream dispatcher and state event dispatcher.

Link copied to clipboard
open fun stop()

Synchronously closes this resource with graceful shutdown.

open fun stop(timeout: Duration)

Synchronously closes this resource with graceful shutdown within a specified timeout.

Link copied to clipboard
open override fun stopGracefully(): Mono<Void>

Stops the composite event dispatcher gracefully by stopping both the event stream dispatcher and state event dispatcher.