using Big.Application; using Microsoft.Extensions.Logging; namespace Big.Infrastructure; /// /// One poll tick of the document-timeout worker (S-10a, ADR-0017): acquire the parked /// RegistratieVerlopen jobs — the tokens the 30-day boundary timer on WachtOpDocumenten /// spawns — expire each correlated registration via the , and /// complete the job so its token reaches endVerlopen. A job that fails is logged and left /// un-completed so Flowable redelivers it (§8.6). Split out from the hosted pump so the /// acquire→expire→complete logic is unit-testable without a running host. Mirrors /// and . /// public sealed class RegistratieVerlopenProcessor( IRegistratieVerlopenClient client, ExpireRegistrationWorker worker, ILogger logger) { /// Acquire and process up to jobs. Returns the number acquired. public async Task PumpOnceAsync(int maxJobs, CancellationToken ct = default) { var jobs = await client.AcquireRegistratieVerlopenJobsAsync(maxJobs, ct); foreach (var job in jobs) { try { await worker.HandleAsync(job, ct); await client.CompleteRegistratieVerlopenJobAsync(job.JobId, ct); } catch (Exception ex) { // Leave the job un-completed: its lock expires and Flowable redelivers it (§8.6). logger.LogError(ex, "RegistratieVerlopen job {JobId} failed; leaving it for redelivery.", job.JobId); } } return jobs.Count; } }