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>
49 lines
1.8 KiB
C#
49 lines
1.8 KiB
C#
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace Big.Infrastructure;
|
|
|
|
/// <summary>
|
|
/// The hosted polling loop of the external-task job worker (ADR-0009): on an interval it resolves a
|
|
/// scoped <see cref="OpenZaakJobProcessor"/> and asks it to drain the parked <c>OpenZaakAanmaken</c>
|
|
/// jobs. A deliberately thin shell — all acquire/process/complete logic lives in the processor, which
|
|
/// is unit-tested; this class only owns the timer, the per-tick scope, and loop resilience.
|
|
/// </summary>
|
|
public sealed class OpenZaakJobPump(
|
|
IServiceScopeFactory scopeFactory,
|
|
FlowableOptions options,
|
|
ILogger<OpenZaakJobPump> logger) : BackgroundService
|
|
{
|
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
|
{
|
|
while (!stoppingToken.IsCancellationRequested)
|
|
{
|
|
try
|
|
{
|
|
using var scope = scopeFactory.CreateScope();
|
|
var processor = scope.ServiceProvider.GetRequiredService<OpenZaakJobProcessor>();
|
|
await processor.PumpOnceAsync(options.MaxJobsPerPoll, stoppingToken);
|
|
}
|
|
catch (OperationCanceledException) when (stoppingToken.IsCancellationRequested)
|
|
{
|
|
break;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
// A transient fault (e.g. Flowable briefly unreachable) must not kill the loop.
|
|
logger.LogError(ex, "OpenZaakAanmaken job poll failed; retrying after the poll interval.");
|
|
}
|
|
|
|
try
|
|
{
|
|
await Task.Delay(options.PollInterval, stoppingToken);
|
|
}
|
|
catch (OperationCanceledException) when (stoppingToken.IsCancellationRequested)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|