FlowableWorkflowClient speaks flowable-rest's REST API (Basic auth): start a registratie process with the registrationId variable, acquire OpenZaakAanmaken external-worker jobs and parse their registrationId, complete a job with the zaakUrl variable — the contract verified against a live engine. AclHttpClient POSTs the bsn to the ACL and returns the zaak URL. InMemoryRegistrationStore is a concurrent-dictionary upsert. OpenZaakJobProcessor drains parked jobs, opening a zaak per job and completing it, leaving failures for redelivery; OpenZaakJobPump is the hosted polling shell that drives it on an interval (ADR-0009). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
40 lines
1.5 KiB
C#
40 lines
1.5 KiB
C#
using Big.Application;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace Big.Infrastructure;
|
|
|
|
/// <summary>
|
|
/// One poll tick of the external-task worker (ADR-0009): acquire the parked <c>OpenZaakAanmaken</c>
|
|
/// jobs, hand each to the <see cref="OpenZaakWorker"/> to open a zaak via the ACL, and complete the
|
|
/// Flowable job with the resulting zaak URL. A job that fails is logged and left un-completed so
|
|
/// Flowable redelivers it (§8.6). Split out from the hosted <see cref="OpenZaakJobPump"/> so the
|
|
/// acquire→process→complete logic is unit-testable without a running host.
|
|
/// </summary>
|
|
public sealed class OpenZaakJobProcessor(
|
|
IExternalWorkerClient client,
|
|
OpenZaakWorker worker,
|
|
ILogger<OpenZaakJobProcessor> 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.AcquireOpenZaakJobsAsync(maxJobs, ct);
|
|
|
|
foreach (var job in jobs)
|
|
{
|
|
try
|
|
{
|
|
var zaakUrl = await worker.HandleAsync(job, ct);
|
|
await client.CompleteOpenZaakJobAsync(job.JobId, zaakUrl, ct);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
// Leave the job un-completed: its lock expires and Flowable redelivers it (§8.6).
|
|
logger.LogError(ex, "OpenZaakAanmaken job {JobId} failed; leaving it for redelivery.", job.JobId);
|
|
}
|
|
}
|
|
|
|
return jobs.Count;
|
|
}
|
|
}
|