BaseOutbox

@MappedSuperclass
abstract class BaseOutbox(var id: Long? = null, eventId: String = UUID.randomUUID().toString(), var topic: String, var key: String, var payload: ByteArray, status: OutboxStatus = OutboxStatus.PENDING, errorMessage: String? = null, var createdAt: Instant = Instant.now(), processedAt: Instant? = null, retryCount: Int = 0, lastRetryAt: Instant? = null, var sagaId: String? = null, var version: Long? = null) : OutboxMessage(source)

JPA @MappedSuperclass providing the column mapping for a Kafka outbox row.

Concrete per-service entities (e.g. OutboxJpaEntity in iam/mail/template) extend this class with their own @Entity + @Table(name = "kafka_outbox") annotations. The base class implements the persistence-agnostic OutboxMessage contract: mutable fields use var with protected set so that Hibernate dirty-tracking can emit partial UPDATE statements while still exposing an effectively-immutable API to callers via behavior methods (DDD rich aggregate).

Mongo/Cassandra adapters can implement these methods by returning a fresh copy of the document instead. The processor never observes the difference.

Constructors

Link copied to clipboard
constructor(id: Long? = null, eventId: String = UUID.randomUUID().toString(), topic: String, key: String, payload: ByteArray, status: OutboxStatus = OutboxStatus.PENDING, errorMessage: String? = null, createdAt: Instant = Instant.now(), processedAt: Instant? = null, retryCount: Int = 0, lastRetryAt: Instant? = null, sagaId: String? = null, version: Long? = null)

Properties

Link copied to clipboard
open override var createdAt: Instant

Instant the row was first written by the producing transaction.

Link copied to clipboard
open override var errorMessage: String?

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

Link copied to clipboard
open override var eventId: String

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

Link copied to clipboard
open override var id: Long?

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

Link copied to clipboard
open override var key: String

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

Link copied to clipboard
open override var lastRetryAt: Instant?

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

Link copied to clipboard
open override var payload: ByteArray

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

Link copied to clipboard
open override var processedAt: Instant?

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

Link copied to clipboard
open override var retryCount: Int

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

Link copied to clipboard
open override var sagaId: String?

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

Link copied to clipboard
open override var status: OutboxStatus

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

Link copied to clipboard
open override var topic: String

Target Kafka topic name.

Link copied to clipboard
open override var version: Long?

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

Functions

Link copied to clipboard
open override fun markCompleted(): OutboxMessage

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
open override fun markDeadLettered(error: String): OutboxMessage

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

Link copied to clipboard
open override fun markProcessing(): OutboxMessage

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

Link copied to clipboard
open override fun markRetryScheduled(error: String): OutboxMessage

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.