Skip to content

feat: Azure Cosmos DB outbox repository (NetEvolve.Pulse.CosmosDb)#422

Open
Copilot wants to merge 2 commits intomainfrom
copilot/add-cosmos-db-outbox-repository
Open

feat: Azure Cosmos DB outbox repository (NetEvolve.Pulse.CosmosDb)#422
Copilot wants to merge 2 commits intomainfrom
copilot/add-cosmos-db-outbox-repository

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 17, 2026

Adds NetEvolve.Pulse.CosmosDb, a native Cosmos DB persistence provider for the outbox pattern, allowing teams using document-oriented architectures on Azure Cosmos DB to avoid introducing a relational database solely for outbox support.

New package: NetEvolve.Pulse.CosmosDb

  • CosmosDbOutboxOptions — configures DatabaseName, ContainerName (default outbox_messages), PartitionKeyPath (default /id), EnableTimeToLive, and TtlSeconds (default 86400)
  • CosmosDbOutboxRepository — full IOutboxRepository implementation using async Cosmos SDK APIs; pending-message claim uses PatchItemAsync with IfMatchEtag for ETag-based optimistic concurrency to prevent duplicate processing
  • CosmosDbOutboxManagement — full IOutboxManagement implementation for dead-letter inspection, replay, and statistics queries
  • CosmosDbExtensionsAddCosmosDbOutbox (registers core outbox + repository) and UseCosmosDbOutbox (repository-only swap) on IMediatorBuilder; CosmosClient must be pre-registered by the caller

Usage

// Register CosmosClient first
services.AddSingleton(new CosmosClient(connectionString, new CosmosClientOptions
{
    Serializer = new CosmosSystemTextJsonSerializer(JsonSerializerOptions.Default)
}));

services.AddPulse(c => c.AddCosmosDbOutbox(opts =>
{
    opts.DatabaseName  = "MyDatabase";
    opts.ContainerName = "outbox_messages";   // default
    opts.EnableTimeToLive = true;             // auto-expire completed/dead-letter docs
    opts.TtlSeconds = 86400;                  // 24 h (default)
}));

Note: The container and database must exist prior to use — automatic schema creation is out of scope. The CosmosClient should be configured with CosmosSystemTextJsonSerializer to align with the System.Text.Json attributes used on the internal document model.

Infrastructure changes

  • Microsoft.Azure.Cosmos 3.58.0 added to Directory.Packages.props
  • Project added to Pulse.slnx and referenced from the unit test project

Known gaps in this PR

  • Unit tests for extensions and repository not yet written
  • Integration tests using Testcontainers Cosmos DB emulator not implemented

Copilot AI linked an issue Apr 17, 2026 that may be closed by this pull request
8 tasks
Copilot AI changed the title [WIP] Add Azure Cosmos DB outbox repository package feat: Azure Cosmos DB outbox repository (NetEvolve.Pulse.CosmosDb) Apr 17, 2026
Copilot AI requested a review from samtrion April 17, 2026 17:50
@samtrion samtrion marked this pull request as ready for review April 18, 2026 10:52
@samtrion samtrion requested a review from a team as a code owner April 18, 2026 10:52
@samtrion samtrion force-pushed the copilot/add-cosmos-db-outbox-repository branch from e5af74c to 69659f1 Compare April 18, 2026 10:52
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.

feat: Azure Cosmos DB outbox repository (NetEvolve.Pulse.CosmosDb)

2 participants