LocalFirstStateEventBus

class LocalFirstStateEventBus(val distributedBus: DistributedStateEventBus, val localBus: LocalStateEventBus = InMemoryStateEventBus()) : StateEventBus, LocalFirstMessageBus<StateEvent<*>, StateEventExchange<*>>

State event bus that prioritizes local message delivery before distributed delivery. Messages are first sent to local subscribers within the same JVM instance, then forwarded to the distributed bus for cross-instance communication. This ensures low-latency local processing while maintaining consistency across instances.

Parameters

distributedBus

The distributed state event bus for cross-instance messaging.

localBus

The local state event bus for same-instance messaging (default: InMemoryStateEventBus).

Constructors

Link copied to clipboard
constructor(distributedBus: DistributedStateEventBus, localBus: LocalStateEventBus = InMemoryStateEventBus())

Properties

Link copied to clipboard
Link copied to clipboard
open override val localBus: LocalStateEventBus
Link copied to clipboard
open override val topicKind: TopicKind

The topic kind for state events.

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 fun receive(namedAggregates: Set<NamedAggregate>): Flux<StateEventExchange<*>>

Receives messages for the specified named aggregates.

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

Sends a message through the message bus.