lockBatchForDispatch

abstract fun lockBatchForDispatch(maxRetries: Int, retriableBefore: Instant, stuckBefore: Instant, batchSize: Int): List<OutboxMessage>(source)

Atomically selects up to batchSize messages eligible for dispatch and locks them with a write lock so that concurrent poller instances skip them (SELECT … FOR UPDATE SKIP LOCKED on PostgreSQL).

A message is eligible when:

Implementations MUST be called within an active transaction so the pessimistic lock survives until the caller updates each row.