OutboxDispatchTx

@Component
class OutboxDispatchTx(outboxRepository: OutboxRepositoryPort)(source)

Transactional helpers for KafkaOutboxProcessor.

Extracted into a separate bean so that calls through the Spring proxy actually open the requested transaction — @Transactional methods that are self-invoked on the same instance bypass the proxy and silently run without a transaction.

Constructors

Link copied to clipboard
constructor(outboxRepository: OutboxRepositoryPort)

Functions

Link copied to clipboard
@Transactional
fun claimBatch(maxRetries: Int, retriableBefore: Instant, stuckBefore: Instant, batchSize: Int): List<OutboxMessage>

Short transaction: select + lock a batch with FOR UPDATE SKIP LOCKED and transition each row to PROCESSING. Commits immediately, freeing the lock so other pollers can proceed.

Link copied to clipboard
@Transactional(propagation = Propagation.REQUIRES_NEW)
fun markCompleted(message: OutboxMessage)

Fresh REQUIRES_NEW transaction that marks message as successfully published. Called after the Kafka broker has acknowledged to send.

Link copied to clipboard
@Transactional(propagation = Propagation.REQUIRES_NEW)
fun rescheduleOrDeadLetter(message: OutboxMessage, error: String, maxRetries: Int)

Fresh REQUIRES_NEW transaction that either: