Skip to content

[Host.Outbox.MongoDb] MongoDb Outbox plugin#464

Open
zarusz wants to merge 1 commit intomasterfrom
feature/mongodb_poutbox
Open

[Host.Outbox.MongoDb] MongoDb Outbox plugin#464
zarusz wants to merge 1 commit intomasterfrom
feature/mongodb_poutbox

Conversation

@zarusz
Copy link
Copy Markdown
Owner

@zarusz zarusz commented Apr 9, 2026

Add MongoDB Transactional Outbox Plugin

Adds SlimMessageBus.Host.Outbox.MongoDb — a new outbox plugin backed by MongoDB, mirroring the existing SQL/PostgreSQL plugins.

What's new

  • AddOutboxUsingMongoDb() — configures the outbox with a MongoDB collection (smb_outbox) and an optional global lock collection (smb_outbox_lock)
  • UseMongoDbTransaction() — wraps consumers in a MongoDB multi-document transaction (requires replica set); the outbox insert automatically participates in the active session
  • IClientSessionHandle? constructor injection — consumers can inject the active session directly without any SMB dependency; works because of the core change below
  • Versioned migrationsMongoDbOutboxMigrationService tracks applied schema changes in smb_outbox_migrations; can be disabled via EnableMigration = false
  • Integration tests — Testcontainers (mongo:8.0) with per-test database isolation

Core SMB change

Consumer instances are now resolved from DI after all interceptors have run (lazy via ConsumerContext.ConsumerFactory), rather than before. This enables interceptors to set up ambient state (e.g. open a DB transaction) that is visible when the consumer's constructor fires.

@zarusz zarusz self-assigned this Apr 9, 2026
@zarusz zarusz added this to the 3.5.0 milestone Apr 9, 2026
@zarusz zarusz force-pushed the feature/mongodb_poutbox branch 4 times, most recently from f713d40 to 306ad56 Compare April 11, 2026 20:40
Signed-off-by: Tomasz Maruszak <maruszaktomasz@gmail.com>
@zarusz zarusz force-pushed the feature/mongodb_poutbox branch from 306ad56 to 41c7d7e Compare April 12, 2026 19:22
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant