Workflow · Reliability
Status Workflow and Background Job Processing
Retry-safe background processing for long-running status transitions with full audit history.
Problem
A status workflow that drove downstream notifications and reporting was occasionally double-processing items after retries, causing duplicate events and noisy alerts.
Business context
Status transitions for regulated records where every change must be auditable and downstream side effects must run exactly once where possible.
My role
Engineer responsible for the workflow engine, idempotency design, audit trail, and production support handoff.
Solution
- Introduced a transition envelope with a stable transition id used as an idempotency key.
- Wrapped each handler in a retry-safe outer loop that records start, success, and failure states.
- Surfaced per-record history so support engineers can see why a transition fired or didn't.
- Added structured logs and correlation IDs spanning API, worker, and downstream calls.
Architecture highlights
- Durable job store in SQL Server with at-least-once delivery semantics.
- Handlers designed to be safely retryable — read current state, decide, persist with a guard.
- Audit table is append-only; the read API joins it to the current state.
Challenges
- Some downstream calls were not idempotent, so the outer envelope had to compensate.
- Backfilling historical records into the new envelope without breaking active workflows.
- Balancing throughput with safe retry intervals.
Outcome / impact
- Reduced duplicate processing risk.
- Improved production support visibility for status-related incidents.
- Improved delivery confidence for downstream consumers.
What I learned
- Idempotency keys belong at the workflow boundary, not inside individual handlers.
- An honest audit trail is the cheapest debugging tool you can ship.
Related posts
Handling Duplicate Background Jobs in .NET with Retry-Safe Logic
Idempotency keys, transition envelopes, and the small patterns that stop background workers from doing the same work twice.
How I Design Enterprise .NET APIs for Maintainability
A practical checklist for designing ASP.NET Core APIs that stay easy to change three releases from now.