CompositeEventDispatcher
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:
EventStreamDispatcher for handling domain event streams.
StateEventDispatcher for handling state-related events.
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
The name of this dispatcher, typically formatted as applicationName.DomainEventDispatcher.
The level of parallelism for processing events. Defaults to MessageParallelism.DEFAULT_PARALLELISM.
The domain event bus for publishing and subscribing to domain events.
The state event bus for handling state-related events.
The registrar for domain event handler functions.
The event handler for processing domain events.
Supplier for creating schedulers for aggregate processing. Defaults to a default implementation.