feat: MongoDB outbox repository (NetEvolve.Pulse.MongoDB)#425
Merged
Conversation
7 tasks
Copilot
AI
changed the title
[WIP] Add MongoDB-backed outbox repository implementation
feat: MongoDB outbox repository (NetEvolve.Pulse.MongoDB)
Apr 18, 2026
c09633d to
83785f9
Compare
83785f9 to
4f5005e
Compare
Agent-Logs-Url: https://github.com/dailydevops/pulse/sessions/47397f30-1217-4ca6-8394-d80e06213321 Co-authored-by: samtrion <3283596+samtrion@users.noreply.github.com>
4f5005e to
dd25569
Compare
Generalize IDatabaseInitializer to IServiceInitializer across all test infra, updating all usages and parameter names for consistency. Add MongoDbOutboxManagement for dead-letter and statistics support, and register IOutboxManagement in MongoDbExtensions. Simplify Redis idempotency test assertions and update MongoDbOutboxTests verified output.
Extract repeated $sum/$cond aggregation logic for OutboxMessageStatus counting into a new StatusCountField method. This reduces code duplication and improves maintainability of the aggregation pipeline.
Extract conversion methods between OutboxDocument and OutboxMessage into a new static OutboxDocumentMapper class. Update MongoDbOutboxRepository and MongoDbOutboxManagement to use this mapper and remove redundant private conversion methods, improving code reuse and maintainability.
Removed unnecessary <DateTime?> generics from MongoDB filter expressions for NextRetryAt, streamlining the code. Improved XML documentation in OutboxDocument.cs by removing redundant namespace qualifications and clarifying date/time storage and conversion details.
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.
Adds
NetEvolve.Pulse.MongoDB— a MongoDB-backedIOutboxRepositoryfor teams using MongoDB as their primary data store, enabling the outbox to coexist in the same database as domain aggregates without introducing a relational dependency.New Package
MongoDbOutboxRepository : IOutboxRepository— full async MongoDB driver implementation. Pending/failed message claiming usesFindOneAndUpdateAsyncin a loop (sorted byCreatedAt) for atomic, concurrent-safe batch acquisition.MongoDbOutboxOptions—DatabaseName(required) andCollectionName(default:outbox_messages).MongoDbExtensions— two registration patterns onIMediatorBuilder:AddMongoDbOutbox(...)— registers core outbox services + MongoDB repository in one call.UseMongoDbOutbox(...)— provider-swap for whenAddOutbox()was already called.IMongoClientmust be pre-registered in DI by the caller.pingcommand.OutboxDocumentmapsOutboxMessagefields via[BsonId]/[BsonElement];DateTimeOffsetstored as UTCDateTimeto avoid BSON representation ambiguity.Usage
Infrastructure
MongoDB.Driver 3.0.0added toDirectory.Packages.props.Testcontainers.MongoDb 4.11.0added for integration tests.DatabaseType.MongoDBadded to the shared enum.Mock.Of<IMongoClient>()due to TUnit.Mocks source-generator limitations with MongoDB.Driver's complex generic interfaces — usesnew MongoClient(...)directly instead).MongoDbContainerFixture(shared Testcontainers instance) with per-test collection isolation viaOutboxOptions.TableName → MongoDbOutboxOptions.CollectionNamebridging.