OutboxMessage

Persistence-agnostic contract for a Kafka outbox message.

The contract is immutable from the caller's perspective: all properties are val and every state transition is expressed as a domain method that returns the new message instance (e.g. markProcessing, markCompleted, markRetryScheduled, markDeadLettered). Concrete adapters decide whether to mutate the underlying row in place (JPA dirty-tracking with var private-set fields) or return a freshly copied document (MongoDB, Cassandra). The outbox processor never observes the difference — it always works with the returned reference.

Inheritors

Properties

Link copied to clipboard
abstract val createdAt: Instant

Instant the row was first written by the producing transaction.

Link copied to clipboard
abstract val errorMessage: String?

Latest publishing error message, or null if the message has never failed.

Link copied to clipboard
abstract val eventId: String

Stable business identifier propagated as the eventId Kafka header (idempotency key on the consumer side).

Link copied to clipboard
abstract val id: Long?

Storage-assigned surrogate id; null until the row is first persisted.

Link copied to clipboard
abstract val key: String

Kafka record key used for partitioning (typically the aggregate id or saga id).

Link copied to clipboard
abstract val lastRetryAt: Instant?

Instant of the most recent retry; used together with veds.outbox.retry-cooldown to throttle redelivery.

Link copied to clipboard
abstract val payload: ByteArray

Serialized record value; encoding (Avro, JSON, …) is the caller's responsibility.

Link copied to clipboard
abstract val processedAt: Instant?

Instant of the most recent dispatch attempt (success or failure).

Link copied to clipboard
abstract val retryCount: Int

Number of publishing attempts already made. Compared against veds.outbox.max-retries.

Link copied to clipboard
abstract val sagaId: String?

Optional saga correlation id (Saga.id) so saga-related outbox rows can be located quickly.

Link copied to clipboard
abstract val status: OutboxStatus

Current lifecycle OutboxStatus. See the enum's KDoc for the state machine.

Link copied to clipboard
abstract val topic: String

Target Kafka topic name.

Link copied to clipboard
abstract val version: Long?

JPA optimistic-locking version, or null for storage backends that do not provide one.

Functions

Link copied to clipboard

Marks the message as successfully published to the broker. Sets status to OutboxStatus.COMPLETED and stamps processedAt with the current instant.

Link copied to clipboard
abstract fun markDeadLettered(error: String): OutboxMessage

Transitions the message to OutboxStatus.DEAD_LETTERED. Terminal — the message will never be retried automatically.

Link copied to clipboard

Marks the message as being currently processed. Sets status to OutboxStatus.PROCESSING and stamps processedAt with the current instant.

Link copied to clipboard

Reverts the message to OutboxStatus.PENDING after a failed publishing attempt, incrementing retryCount and stamping lastRetryAt. The message will be picked up again by the next poller cycle after the configured retry cooldown elapses.