Skip to content

Add opt-in outbox and inbox retention sweeps#239

Merged
Vulthil merged 2 commits into
mainfrom
feature/outbox-inbox-retention
Jun 18, 2026
Merged

Add opt-in outbox and inbox retention sweeps#239
Vulthil merged 2 commits into
mainfrom
feature/outbox-inbox-retention

Conversation

@Vulthil

@Vulthil Vulthil commented Jun 17, 2026

Copy link
Copy Markdown
Owner

Summary

Opt-in retention so the outbox and inbox tables don't grow unbounded. Follows #226, #232, #235 (merged).

A single opt-in background sweep per concern periodically deletes terminal rows older than a window, via a store-level DeleteProcessedAsync seam. Same mechanism for relational and Cosmos — no TTL (a Cosmos container TTL can't tell a pending outbox row from a relayed one, and could expire an undelivered message). No breaking changes: IOutboxStore / IIdempotencyStore are untouched; the delete lives on new IOutboxRetentionStore / IInboxRetentionStore the EF Core stores also implement. There is no Enabled flag — registering the sweep is the opt-in.

Outbox (Vulthil.SharedKernel.Outbox)

  • AddOutboxRetention(...) + OutboxRetentionOptions (RetentionPeriod 7d, SweepInterval 1h, BatchSize 1000).
  • EntityFrameworkOutboxStore.DeleteProcessedAsync (base: materialize + RemoveRange, used by Cosmos); RelationalOutboxStore overrides with set-based ExecuteDelete. Deletes rows with ProcessedOnUtc or FailedOnUtc past the window; pending rows are never touched.

Inbox (Vulthil.Messaging.Inbox)

  • AddInboxRetention(...) + InboxRetentionOptions. DeleteProcessedAsync on the relational (ExecuteDelete) and Cosmos (RemoveRange) idempotency stores. Docs warn to keep the window comfortably longer than the broker's max redelivery delay.

Samples, tests, docs

  • The WebApi sample calls AddOutboxRetention() + AddInboxRetention().
  • Store-level delete tests for outbox + inbox (old terminal rows go; recent and pending stay).
  • Retention sections in both pattern articles + a bullet in each package doc.

Verification

Full Release build clean; retention suites pass (outbox 8/8, inbox 6/6); WebApi.Tests 8/8 with the sweeps registered.

@claude

claude Bot commented Jun 18, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@Vulthil
Vulthil merged commit d85c339 into main Jun 18, 2026
5 checks passed
@Vulthil
Vulthil deleted the feature/outbox-inbox-retention branch June 18, 2026 18:33
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