From 33160fa7d0aab8dee00320d7e677c9694dbf089e Mon Sep 17 00:00:00 2001 From: Niek Otten Date: Fri, 17 Jul 2026 09:04:53 +0200 Subject: [PATCH] feat(workflow): escalation drain loop reassigns then completes (S-14, refs #15) Implement BeoordelingEscalatieProcessor.PumpOnceAsync over the escalation client. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../BeoordelingEscalatieProcessor.cs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/services/domain/Big.Infrastructure/BeoordelingEscalatieProcessor.cs b/services/domain/Big.Infrastructure/BeoordelingEscalatieProcessor.cs index 931ec53..a2dac9f 100644 --- a/services/domain/Big.Infrastructure/BeoordelingEscalatieProcessor.cs +++ b/services/domain/Big.Infrastructure/BeoordelingEscalatieProcessor.cs @@ -14,6 +14,24 @@ public sealed class BeoordelingEscalatieProcessor( ILogger logger) { /// Acquire and process up to escalations. Returns the number acquired. - public Task PumpOnceAsync(int maxJobs, CancellationToken ct = default) - => throw new NotImplementedException(); + public async Task PumpOnceAsync(int maxJobs, CancellationToken ct = default) + { + var jobs = await client.AcquireBeoordelingEscalatieJobsAsync(maxJobs, ct); + + foreach (var job in jobs) + { + try + { + await client.ReassignBeoordelingToTeamleadAsync(job.ProcessInstanceId, ct); + await client.CompleteBeoordelingEscalatieJobAsync(job.JobId, ct); + } + catch (Exception ex) + { + // Leave the job un-completed: its lock expires and Flowable redelivers it (ยง8.6). + logger.LogError(ex, "BeoordelingEscaleren job {JobId} failed; leaving it for redelivery.", job.JobId); + } + } + + return jobs.Count; + } }