Skip to content

Add lightweight bounded background job queue - #18

Merged
balajibashyam merged 4 commits into
mainfrom
feature/background-job-queue-sample
Aug 6, 2026
Merged

Add lightweight bounded background job queue#18
balajibashyam merged 4 commits into
mainfrom
feature/background-job-queue-sample

Conversation

@balajibashyam

Copy link
Copy Markdown
Contributor

Summary

Adds a minimal .NET 10 companion sample for the .NET 8 Background Jobs: IBackgroundTaskQueue, BackgroundService & Production-Ready Patterns tutorial.

What's included

  • New sample: dotnet-8-essentials/background-jobs-hostedservice-queues/ — 14 files

    • Typed EmailJob record, bounded Channel<EmailJob> with asynchronous backpressure
    • BackgroundService consumer with fresh async DI scope per job
    • Scoped IEmailJobHandler with deterministic fake processing
    • In-memory job tracker with Queued/Running/Succeeded/Failed/Canceled states
    • Minimal API: POST /jobs/email (202), GET /jobs/{jobId}, GET /jobs/queue
    • Request validation, safe failure messages, cancellation propagation
    • 8 xUnit v3 integration tests proving FIFO, backpressure, completion drain, fresh scopes, failure isolation, cancellation, API 202, and validation 400
  • Root README: New sample row in the samples table + updated repository structure tree

  • GitHub Actions: New test-background-job-queue job in the shared workflow; path filters updated for push and pull_request

Deliberately omitted (stays in the full tutorial)

Retries, Polly, dead-letter storage, schedules, metrics exporters, health probes, durable brokers, databases, real email delivery, multiple workers, parallel processing.

Versions

  • .NET SDK: 10.0.302
  • Microsoft.AspNetCore.Mvc.Testing: 10.0.10
  • xunit.v3: 3.2.2
  • Application NuGet dependencies: zero

Validation

  • dotnet restore — passed
  • dotnet build --configuration Release — passed (0 errors, 0 warnings)
  • dotnet test --configuration Release — passed (8/8)
  • Security scan — clean
  • Runtime smoke test — root JSON exact match, queue JSON exact match, enqueue returned 202, invalid request returned 400

@balajibashyam
balajibashyam merged commit 86223e4 into main Aug 6, 2026
@balajibashyam
balajibashyam deleted the feature/background-job-queue-sample branch August 6, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant