KubeMQ
Client SDKsKotlinReference

Events Store

Durable events with replay -- KubeMQ Kotlin SDK reference.

PubSubClient exposes publishEventStore, publishEventStoreStream, and subscribeToEventsStore for persisted events with configurable replay positions.

publishEventStore

suspend fun publishEventStore(message: EventStoreMessage): EventSendResult

Persists an event and returns acknowledgement metadata.

Parameters:

NameTypeRequiredDescription
messageEventStoreMessageYesBuilt via eventStoreMessage { } DSL

Returns: EventSendResult -- IDs, timestamps, and sent flag from the broker.

publishEventStoreStream

fun publishEventStoreStream(events: Flow<EventStoreMessage>): Flow<EventSendResult>

Streams persistent events for high-throughput publishing.

subscribeToEventsStore

fun subscribeToEventsStore(config: EventsStoreSubscriptionConfig.() -> Unit): Flow<EventMessageReceived>

Returns a cold Flow that subscribes with replay parameters.

Configuration DSL:

PropertyTypeRequiredDescription
channelStringYesChannel to subscribe to
groupStringNoConsumer group
startPositionStartPositionYesReplay start position

Replay options (StartPosition)

ValueDescription
StartPosition.StartNewOnlyOnly new events after subscription
StartPosition.StartFromFirstReplay from the very first event
StartPosition.StartFromLastLast event plus new ones
StartPosition.StartAtSequence(n)Replay from sequence number n
StartPosition.StartAtTime(nanos)Replay from timestamp (nanos since epoch)
StartPosition.StartAtTimeDelta(seconds)Replay from seconds ago

eventStoreMessage DSL

eventStoreMessage {
    channel = "events-store.orders"
    body = payload.toByteArray()
    metadata = "order-service"
}

Quick Usage

EventsStore.kt
KubeMQClient.pubSub {
    address = "localhost:50000"
    clientId = "store-demo"
}.use { pub ->
    pub.publishEventStore(eventStoreMessage {
        channel = "audit.security"
        body = payload.toByteArray()
    })
}

See Also

Was this page helpful?

On this page