Adds RegistratieVerlopenJob, IRegistratieVerlopenClient, the ExpireRegistrationWorker application handler, and the RegistratieVerlopenProcessor drain loop — the timeout counterpart to the OpenZaak/escalation worker trios. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
42 lines
1.7 KiB
C#
42 lines
1.7 KiB
C#
using Big.Application;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace Big.Infrastructure;
|
|
|
|
/// <summary>
|
|
/// One poll tick of the document-timeout worker (S-10a, ADR-0017): acquire the parked
|
|
/// <c>RegistratieVerlopen</c> jobs — the tokens the 30-day boundary timer on <c>WachtOpDocumenten</c>
|
|
/// spawns — expire each correlated registration via the <see cref="ExpireRegistrationWorker"/>, and
|
|
/// complete the job so its token reaches <c>endVerlopen</c>. 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
|
|
/// <see cref="OpenZaakJobProcessor"/> and <see cref="BeoordelingEscalatieProcessor"/>.
|
|
/// </summary>
|
|
public sealed class RegistratieVerlopenProcessor(
|
|
IRegistratieVerlopenClient client,
|
|
ExpireRegistrationWorker worker,
|
|
ILogger<RegistratieVerlopenProcessor> logger)
|
|
{
|
|
/// <summary>Acquire and process up to <paramref name="maxJobs"/> jobs. Returns the number acquired.</summary>
|
|
public async Task<int> 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;
|
|
}
|
|
}
|