Excalibur.Outbox.CosmosDb
3.0.0-alpha.19
This is a prerelease version of Excalibur.Outbox.CosmosDb.
dotnet add package Excalibur.Outbox.CosmosDb --version 3.0.0-alpha.19
NuGet\Install-Package Excalibur.Outbox.CosmosDb -Version 3.0.0-alpha.19
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Excalibur.Outbox.CosmosDb" Version="3.0.0-alpha.19" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Excalibur.Outbox.CosmosDb" Version="3.0.0-alpha.19" />
<PackageReference Include="Excalibur.Outbox.CosmosDb" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Excalibur.Outbox.CosmosDb --version 3.0.0-alpha.19
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Excalibur.Outbox.CosmosDb, 3.0.0-alpha.19"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Excalibur.Outbox.CosmosDb@3.0.0-alpha.19
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Excalibur.Outbox.CosmosDb&version=3.0.0-alpha.19&prerelease
#tool nuget:?package=Excalibur.Outbox.CosmosDb&version=3.0.0-alpha.19&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Excalibur.Outbox.CosmosDb
Azure Cosmos DB implementation of the cloud-native outbox pattern for reliable message delivery.
Features
- Transactional outbox pattern with partition-aware storage
- Change feed subscription for push-based message processing
- Cost-aware operations with RU tracking
- Automatic TTL cleanup for published messages
- Serverless-friendly - designed for Azure Functions triggers
Installation
dotnet add package Excalibur.Outbox.CosmosDb
Configuration
services.AddCosmosDbOutboxStore(options =>
{
options.ConnectionString = "AccountEndpoint=...;AccountKey=...";
options.DatabaseName = "mydb";
options.ContainerName = "outbox";
options.DefaultTimeToLiveSeconds = 604800; // 7 days
options.CreateContainerIfNotExists = true;
});
Or via configuration:
services.AddCosmosDbOutboxStore(configuration.GetSection("CosmosDbOutbox"));
Usage
Adding Messages to the Outbox
public class MyService
{
private readonly ICloudNativeOutboxStore _outbox;
public MyService(ICloudNativeOutboxStore outbox)
{
_outbox = outbox;
}
public async Task PublishEventAsync(OrderPlaced @event, CancellationToken ct)
{
var message = new CloudOutboxMessage
{
MessageId = Guid.NewGuid().ToString(),
MessageType = nameof(OrderPlaced),
Payload = JsonSerializer.SerializeToUtf8Bytes(@event),
AggregateId = @event.OrderId,
AggregateType = "Order",
PartitionKeyValue = @event.OrderId,
CreatedAt = DateTimeOffset.UtcNow
};
var partitionKey = new PartitionKey(@event.OrderId);
var result = await _outbox.AddAsync(message, partitionKey, ct);
if (!result.Success)
{
// Handle failure
}
}
}
Processing Messages with Change Feed
// Subscribe to new outbox messages
var subscription = await _outbox.SubscribeToNewMessagesAsync(
new ChangeFeedOptions { StartPosition = ChangeFeedStartPosition.Now },
ct);
await foreach (var change in subscription.ReadChangesAsync(ct))
{
if (change.Document != null)
{
// Publish to message broker
await _messageBroker.PublishAsync(change.Document);
// Mark as published
await _outbox.MarkAsPublishedAsync(
change.DocumentId,
change.PartitionKey,
ct);
}
}
Using with Azure Functions
For serverless scenarios, use the Cosmos DB change feed trigger:
[FunctionName("OutboxProcessor")]
public async Task ProcessOutboxMessages(
[CosmosDBTrigger(
databaseName: "mydb",
containerName: "outbox",
Connection = "CosmosDbConnection",
LeaseContainerName = "leases",
CreateLeaseContainerIfNotExists = true)]
IReadOnlyList<OutboxDocument> documents,
CancellationToken ct)
{
foreach (var doc in documents.Where(d => !d.IsPublished))
{
await _messageBroker.PublishAsync(doc);
await _outbox.MarkAsPublishedAsync(doc.Id, new PartitionKey(doc.PartitionKey), ct);
}
}
Document Schema
The outbox uses the following Cosmos DB document schema:
| Field | Type | Description |
|---|---|---|
| id | String | Unique message identifier |
| partitionKey | String | Partition key value |
| messageType | String | Message type name |
| payload | String | Base64-encoded message payload |
| headers | String | JSON-encoded headers |
| aggregateId | String | Associated aggregate ID |
| aggregateType | String | Associated aggregate type |
| correlationId | String | Correlation ID for tracing |
| causationId | String | Causation ID linking to causing message |
| createdAt | String | ISO 8601 timestamp |
| publishedAt | String | ISO 8601 timestamp when published |
| isPublished | Boolean | Publication status |
| retryCount | Number | Number of retry attempts |
| lastError | String | Last error message |
| ttl | Number | Time-to-live in seconds |
Requirements
- .NET 9.0+
- Azure Cosmos DB account or emulator
Excalibur.Data.Abstractionsfor cloud-native interfacesExcalibur.Data.CosmosDbfor Cosmos DB SDK setup
License
See LICENSE files in repository root.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- AWSSDK.Core (>= 4.0.3.8)
- AWSSDK.SecurityToken (>= 4.0.5.6)
- Ben.Demystifier (>= 0.4.1)
- CloudNative.CloudEvents (>= 2.8.0)
- CloudNative.CloudEvents.SystemTextJson (>= 2.8.0)
- Cronos (>= 0.11.1)
- Dapper (>= 2.1.66)
- Excalibur.Data.Abstractions (>= 3.0.0-alpha.19)
- Excalibur.Data.CosmosDb (>= 3.0.0-alpha.19)
- Excalibur.Outbox (>= 3.0.0-alpha.19)
- Medo.Uuid7 (>= 1.4.0)
- MemoryPack (>= 1.21.4)
- Microsoft.ApplicationInsights (>= 2.23.0)
- Microsoft.AspNetCore.Authorization (>= 9.0.9)
- Microsoft.Azure.Cosmos (>= 3.47.0)
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Caching.Memory (>= 10.0.0)
- Microsoft.Extensions.Configuration (>= 10.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.0)
- Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Http (>= 10.0.0)
- Microsoft.Extensions.Logging (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.ObjectPool (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.0)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.0)
- MongoDB.Driver (>= 2.25.0)
- NCrontab (>= 3.4.0)
- Npgsql (>= 9.0.4)
- OpenTelemetry (>= 1.13.0)
- OpenTelemetry.Api (>= 1.13.0)
- OpenTelemetry.Extensions.Hosting (>= 1.13.0)
- QuestPDF (>= 2024.12.2)
- Snappier (>= 1.2.0)
- System.Threading.RateLimiting (>= 10.0.0)
-
net8.0
- AWSSDK.Core (>= 4.0.3.8)
- AWSSDK.SecurityToken (>= 4.0.5.6)
- Ben.Demystifier (>= 0.4.1)
- CloudNative.CloudEvents (>= 2.8.0)
- CloudNative.CloudEvents.SystemTextJson (>= 2.8.0)
- Cronos (>= 0.11.1)
- Dapper (>= 2.1.66)
- Excalibur.Data.Abstractions (>= 3.0.0-alpha.19)
- Excalibur.Data.CosmosDb (>= 3.0.0-alpha.19)
- Excalibur.Outbox (>= 3.0.0-alpha.19)
- Medo.Uuid7 (>= 1.4.0)
- MemoryPack (>= 1.21.4)
- Microsoft.ApplicationInsights (>= 2.23.0)
- Microsoft.AspNetCore.Authorization (>= 9.0.9)
- Microsoft.Azure.Cosmos (>= 3.47.0)
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Caching.Memory (>= 10.0.0)
- Microsoft.Extensions.Configuration (>= 10.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.0)
- Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Http (>= 10.0.0)
- Microsoft.Extensions.Logging (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.ObjectPool (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.0)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.0)
- MongoDB.Driver (>= 2.25.0)
- NCrontab (>= 3.4.0)
- Npgsql (>= 9.0.4)
- OpenTelemetry (>= 1.13.0)
- OpenTelemetry.Api (>= 1.13.0)
- OpenTelemetry.Extensions.Hosting (>= 1.13.0)
- QuestPDF (>= 2024.12.2)
- Snappier (>= 1.2.0)
- System.Diagnostics.DiagnosticSource (>= 10.0.0)
- System.IO.Pipelines (>= 10.0.0)
- System.Text.Json (>= 10.0.0)
- System.Threading.Channels (>= 10.0.0)
- System.Threading.RateLimiting (>= 10.0.0)
-
net9.0
- AWSSDK.Core (>= 4.0.3.8)
- AWSSDK.SecurityToken (>= 4.0.5.6)
- Ben.Demystifier (>= 0.4.1)
- CloudNative.CloudEvents (>= 2.8.0)
- CloudNative.CloudEvents.SystemTextJson (>= 2.8.0)
- Cronos (>= 0.11.1)
- Dapper (>= 2.1.66)
- Excalibur.Data.Abstractions (>= 3.0.0-alpha.19)
- Excalibur.Data.CosmosDb (>= 3.0.0-alpha.19)
- Excalibur.Outbox (>= 3.0.0-alpha.19)
- Medo.Uuid7 (>= 1.4.0)
- MemoryPack (>= 1.21.4)
- Microsoft.ApplicationInsights (>= 2.23.0)
- Microsoft.AspNetCore.Authorization (>= 9.0.9)
- Microsoft.Azure.Cosmos (>= 3.47.0)
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Caching.Memory (>= 10.0.0)
- Microsoft.Extensions.Configuration (>= 10.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.0)
- Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Http (>= 10.0.0)
- Microsoft.Extensions.Logging (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.ObjectPool (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.0)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.0)
- MongoDB.Driver (>= 2.25.0)
- NCrontab (>= 3.4.0)
- Npgsql (>= 9.0.4)
- OpenTelemetry (>= 1.13.0)
- OpenTelemetry.Api (>= 1.13.0)
- OpenTelemetry.Extensions.Hosting (>= 1.13.0)
- QuestPDF (>= 2024.12.2)
- Snappier (>= 1.2.0)
- System.Diagnostics.DiagnosticSource (>= 10.0.0)
- System.IO.Pipelines (>= 10.0.0)
- System.Text.Json (>= 10.0.0)
- System.Threading.Channels (>= 10.0.0)
- System.Threading.RateLimiting (>= 10.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0-alpha.19 | 36 | 2/26/2026 |