Adds Inbox support to Mocha#9332
Merged
PascalSenn merged 10 commits intomainfrom Mar 9, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds inbox (idempotent consumer) support to the Mocha messaging framework. The inbox complements the existing transactional outbox by deduplicating incoming messages on the receiving side, enabling effectively exactly-once message processing. The implementation includes a new Mocha.Inbox library, Postgres-backed inbox persistence via EF Core, a background cleanup worker, consumer middleware for deduplication, comprehensive tests, and documentation updates.
Changes:
- New
Mocha.Inboxproject withIMessageInboxinterface,ConsumeInboxMiddleware,InboxCleanupProcessor,MessageBusInboxWorker, and supporting types for inbox feature control and configuration. - Postgres inbox persistence (
PostgresMessageInbox, EF Core entity configuration, SQL queries, migrations) integrated into all three demo services (Catalog, Billing, Shipping) and the OutboxInbox example. - Documentation updates across reliability, middleware, routing, transport, and index pages to describe the inbox feature and its interaction with the outbox for exactly-once delivery guarantees.
Reviewed changes
Copilot reviewed 55 out of 58 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
src/Mocha/src/Mocha.Inbox/ (new project) |
Core inbox library: interface, middleware, cleanup worker, options, feature flag |
src/Mocha/src/Mocha.EntityFrameworkCore.Postgres/Inbox/ |
Postgres inbox implementation: SQL queries, EF Core config, service registration |
src/Mocha/src/Mocha.EntityFrameworkCore.Postgres/PostgresTableInfo.cs |
Refactored: extracted OutboxTableInfo and SagaStateTableInfo to own files, added InboxTableInfo |
src/Mocha/src/Mocha.EntityFrameworkCore.Postgres/OutboxTableInfo.cs |
Extracted from PostgresTableInfo.cs |
src/Mocha/src/Mocha.EntityFrameworkCore.Postgres/SagaStateTableInfo.cs |
Extracted from PostgresTableInfo.cs |
src/Mocha/src/Mocha.EntityFrameworkCore.Postgres/InboxTableInfo.cs |
New table info for inbox messages |
src/Mocha/src/Mocha.Threading/ContinuousTask.cs |
Bug fix: await background task before disposing CTS in DisposeAsync |
src/Mocha/src/Mocha/Assembly.cs |
Added InternalsVisibleTo for Mocha.Inbox |
src/Mocha/src/Mocha/README.md |
Removed internal pipeline documentation |
Demo services (Catalog, Billing, Shipping) |
Added inbox registration, DbContext config, and EF migrations |
src/Mocha/src/Examples/Reliability/OutboxInbox/ |
Updated example to include inbox setup |
Test projects (Mocha.Tests, InMemory.Tests, RabbitMQ.Tests, Postgres.Tests) |
New inbox unit, integration, and behavioral tests |
website/src/docs/mocha/v1/reliability.md |
Major documentation addition for inbox feature |
website/src/docs/mocha/v1/index.md |
Fixed AddPostgresInbox → UsePostgresInbox |
website/src/docs/mocha/v1/middleware-and-pipelines.md |
Added inbox to pipeline diagram and middleware list |
website/src/docs/mocha/v1/routing-and-endpoints.md |
Updated next steps link description |
website/src/docs/mocha/v1/transports/rabbitmq.md |
Updated reliability link descriptions |
Files not reviewed (3)
- src/Mocha/src/Demo/Demo.Billing/Migrations/20260307183420_AddInboxMessage.Designer.cs: Language not supported
- src/Mocha/src/Demo/Demo.Catalog/Migrations/20260307183409_AddInboxMessage.Designer.cs: Language not supported
- src/Mocha/src/Demo/Demo.Shipping/Migrations/20260307183427_AddInboxMessage.Designer.cs: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…age deduplication
This was referenced May 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.