Franz.Common.MongoDB 1.6.2

dotnet add package Franz.Common.MongoDB --version 1.6.2
                    
NuGet\Install-Package Franz.Common.MongoDB -Version 1.6.2
                    
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="Franz.Common.MongoDB" Version="1.6.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Franz.Common.MongoDB" Version="1.6.2" />
                    
Directory.Packages.props
<PackageReference Include="Franz.Common.MongoDB" />
                    
Project file
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 Franz.Common.MongoDB --version 1.6.2
                    
#r "nuget: Franz.Common.MongoDB, 1.6.2"
                    
#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 Franz.Common.MongoDB@1.6.2
                    
#: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=Franz.Common.MongoDB&version=1.6.2
                    
Install as a Cake Addin
#tool nuget:?package=Franz.Common.MongoDB&version=1.6.2
                    
Install as a Cake Tool

Got it ✅ — let’s update the README for Franz.Common.MongoDB v1.6.2 to reflect all the new changes we introduced (Inbox store, Outbox store, DLQ, indexes, DI extensions, etc.).

Here’s the rewritten version:


# Franz.Common.MongoDB

A library within the **Franz Framework** designed to streamline the integration of MongoDB into .NET applications.  
This package provides utilities for configuring MongoDB services, registering them with dependency injection, and enabling reliable **messaging persistence** patterns such as **Outbox** and **Inbox**.

---

## ✨ Features

- **MongoDB Service Registration**
  - `MongoServiceRegistration` for simplified client and database registration.
  - Options-driven configuration via `MongoOptions`.

- **📦 Outbox Support**
  - `MongoMessageStore` for storing pending messages.
  - Automatic retry and **Dead Letter Queue (DLQ)** support.
  - Auto-created indexes on:
    - `SentOn` (pending lookups)
    - `RetryCount` (retry cycles)
    - `CreatedOn` (cleanup/archival)

- **📥 Inbox Support**
  - `MongoInboxStore` ensures **idempotent message consumption**.
  - Unique index on processed message IDs prevents duplicates.

- **⚙️ Dependency Injection**
  - Extensions for clean setup:
    - `AddMongoMessageStore`
    - `AddMongoInboxStore`
    - `AddMongoDB`

- **🔒 Reliability**
  - Atomic updates for retries (`UpdateRetryAsync`).
  - Safe move to dead-letter collection (`MoveToDeadLetterAsync`).
  - Mark-as-sent functionality for outbox messages.

---

## 📂 Project Structure

Franz.Common.MongoDB/ ├── Configuration/ │ └── MongoOptions.cs ├── Outbox/ │ ├── MongoMessageStore.cs │ └── DeadLetterCollection.cs ├── Inbox/ │ └── MongoInboxStore.cs ├── Extensions/ │ └── ServiceCollectionExtensions.cs └── MongoServiceRegistration.cs


---

## ⚙️ Configuration

`appsettings.json`:

```json
"Mongo": {
  "ConnectionString": "mongodb://localhost:27017",
  "DatabaseName": "MessagingDb",
  "OutboxCollection": "OutboxMessages",
  "DeadLetterCollection": "DeadLetterMessages",
  "InboxCollection": "InboxMessages"
}

🚀 Dependency Injection Setup

builder.Services.AddMongoDB(options =>
{
    options.ConnectionString = "mongodb://localhost:27017";
    options.DatabaseName = "MessagingDb";
});

builder.Services.AddMongoMessageStore(configuration);
builder.Services.AddMongoInboxStore(configuration);

🔄 Usage

Outbox Message Store

var message = new StoredMessage
{
    Id = Guid.NewGuid().ToString(),
    Body = "{ \"OrderId\": 123 }",
    CreatedOn = DateTime.UtcNow
};

await _messageStore.SaveAsync(message);

Inbox Message Store

if (!await _inboxStore.HasProcessedAsync(message.Id))
{
    await _dispatcher.PublishAsync(orderCreatedEvent);
    await _inboxStore.MarkProcessedAsync(message.Id);
}

📊 Observability

  • Mongo collections come with indexes for performance.
  • Logs include retries ⚠️, DLQ moves 🔥, and successful sends ✅.
  • OpenTelemetry hooks enabled via higher-level messaging layer.

📌 Roadmap

  • TTL indexes for automatic cleanup of old outbox/inbox entries.
  • Configurable sharding/replica set support for large-scale deployments.
  • RabbitMQ-backed inbox/outbox stores (parallel to Kafka).

📝 Version Information

  • Current Version: 1.6.2
  • Part of the private Franz Framework ecosystem.

📜 License

This library is licensed under the MIT License. See the LICENSE file for details.


📖 Changelog

Version 1.2.65

  • Added MongoServiceRegistration for streamlined MongoDB service configuration and registration.
  • Introduced support for custom MongoDB configurations.

Version 1.3

  • Upgraded to .NET 9.0.8.
  • Added new features and improvements.
  • Separated business concepts from mediator concepts.
  • Now compatible with both the in-house mediator and MediatR.

Version 1.6.2

  • Introduced Mongo Outbox (MongoMessageStore) with retries and Dead Letter Queue.

  • Added Mongo Inbox (MongoInboxStore) for idempotent consumption.

  • Auto-created indexes on SentOn, RetryCount, and CreatedOn.

  • Added dependency injection extensions:

    • AddMongoMessageStore
    • AddMongoInboxStore
  • Extended IMessageStore with:

    • UpdateRetryAsync
    • MoveToDeadLetterAsync
    • MarkAsSentAsync
  • Improved observability with structured logging and OpenTelemetry hooks.



---

Product Compatible and additional computed target framework versions.
.NET 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 was computed.  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.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Franz.Common.MongoDB:

Package Downloads
Franz.Common.Messaging.EntityFramework

Shared utility library for the Franz Framework.

Franz.Common.Http.EntityFramework

Shared utility library for the Franz Framework.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.6.2 0 10/7/2025
1.5.9 164 9/24/2025
1.5.4 160 9/23/2025
1.5.3 210 9/21/2025
1.5.2 213 9/21/2025
1.5.0 205 9/21/2025
1.4.4 179 9/20/2025
1.3.14 294 9/18/2025
1.3.13 278 9/18/2025
1.3.5 290 9/17/2025
1.3.4 302 9/16/2025
1.3.3 291 9/16/2025
1.3.2 281 9/15/2025
1.3.1 95 9/12/2025
1.3.0 313 8/25/2025
1.2.65 178 3/3/2025
1.2.64 132 1/29/2025
1.2.63 118 1/27/2025
1.2.62 126 1/8/2025