All checks were successful
CI / lint (pull_request) Successful in 1m15s
CI / build (pull_request) Successful in 1m1s
CI / unit (pull_request) Successful in 1m20s
CI / frontend (pull_request) Successful in 2m50s
CI / mutation (pull_request) Successful in 5m22s
CI / verify-stack (pull_request) Successful in 7m18s
verify-stack surfaced a Flowable 500: delivering messageEventReceived to the Beoordelen task's execution is wrong — a message boundary event's subscription lives on its own execution. Correlate instead by the registration's process instance id (recorded at submit): query the execution subscribed to RegistratieIngetrokken and deliver the message there. Withdrawal moves from IUserTaskClient to IWorkflowClient.WithdrawProcessAsync; the handler no longer needs a task lookup. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
38 lines
1.9 KiB
C#
38 lines
1.9 KiB
C#
using Big.Domain;
|
|
|
|
namespace Big.Application;
|
|
|
|
/// <summary>A zorgprofessional's request to withdraw their own registration ("trek aanvraag in").</summary>
|
|
public sealed record WithdrawRegistrationCommand(RegistrationId RegistrationId);
|
|
|
|
/// <summary>
|
|
/// The withdrawal use case (S-11): a zorgprofessional pulls a still-open registration back. It
|
|
/// advances the aggregate to INGETROKKEN, persists it, then cancels the running registratie process
|
|
/// by correlating the withdrawal message to its instance (ADR-0014), so the case leaves the
|
|
/// behandelaar's werkbak. Idempotent — a repeated or redelivered withdrawal of an already-withdrawn
|
|
/// registration is a no-op (not persisted or cancelled again). Cancelling is best-effort: if the
|
|
/// registration never started a process the withdrawal still stands (the process cancel is skipped),
|
|
/// mirroring how <see cref="BeoordeelRegistratie"/> completes its task best-effort.
|
|
/// </summary>
|
|
public sealed class WithdrawRegistration(IRegistrationStore store, IWorkflowClient workflow)
|
|
{
|
|
public async Task HandleAsync(WithdrawRegistrationCommand command, CancellationToken ct = default)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(command);
|
|
|
|
var registration = await store.GetAsync(command.RegistrationId, ct)
|
|
?? throw new InvalidOperationException($"No registration {command.RegistrationId} to withdraw.");
|
|
|
|
// A repeated withdrawal is a no-op: don't persist or cancel the already-withdrawn one again.
|
|
if (registration.Status == RegistrationStatus.Ingetrokken)
|
|
return;
|
|
|
|
registration.Withdraw();
|
|
await store.SaveAsync(registration, ct);
|
|
|
|
// Cancel the running process (if one was started) so its Beoordelen task leaves the werkbak.
|
|
if (registration.ProcessInstanceId is not null)
|
|
await workflow.WithdrawProcessAsync(registration.ProcessInstanceId, ct);
|
|
}
|
|
}
|