claim

open override fun claim(batchSize: Int, atTime: Instant, lease: Duration): List<Postbox.PendingRequest>(source)

Atomically claim a batch of due requests for processing, marking them as RequestProcessingStatus.Processing until either they are finalised via markProcessed, markFailed or markDead, or until the given lease expires (after which they can be reclaimed by a subsequent call).

Requests that were claimed previously but whose lease has now expired are reclaimed (returned to pending) before the next batch is selected, so that crashed or abandoned processors do not leave requests stuck.

Request claims are exclusive: a request that is still within its lease will not be returned to another caller.

Return

the list of claimed requests in first-in-first-out order, limited to batchSize

Parameters

batchSize

the maximum number of requests to claim in a single batch

atTime

the time against which due requests are evaluated

lease

the duration for which a claim is held before it can be reclaimed by another processor