YAMCqrs.EventBus.Storage.MongoDb 10.0.1

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

YAMCqrs.EventBus.Storage.MongoDb

Documentacion en español

Persistent storage implementation for YAMCqrs.EventBus.Core using MongoDB.

This package DOES NOT use MongoDB as a messaging broker.

MongoDB is used exclusively as a persistence mechanism for:

  • storing pending events
  • decoupling event processing
  • enabling execution in independent scopes
  • supporting retries
  • maintaining auditing and event tracking

Actual event delivery and consumption remain the responsibility of the configured messaging provider (Kafka, RabbitMQ, etc).


⚙️ Installation

dotnet add package YAMCqrs.EventBus.Storage.MongoDb

🚀 Quick Start

Register MongoDB Storage in the dependency injection container:

builder.Services.AddEventBus(opt =>
{
    // Base EventBus configuration
})
.UseMongoDb(new EventBusStorageMongoConfiguration()
{
    ConnectionString = "cs_MongoDb",
    DatabaseName = "TestAppDb",
});

Using "cs_MongoDb" as the ConnectionString instructs the library to automatically resolve the value from ConnectionStrings:MongoDb following ADR 13.


⚙️ Configuration

EventBusStorageMongoConfiguration

  • ConnectionString Connection string used to connect to MongoDB.

  • DatabaseName Database name used for event persistence.


🛠️ Architectural Purpose

Decoupled persistence enables the EventBus to:

  • process events outside the original scope
  • decouple publishing and processing
  • survive application restarts
  • implement safe retries
  • maintain full auditing
  • reduce broker coupling

This enables patterns similar to:

  • Outbox Pattern
  • Inbox Pattern
  • Event Auditing
  • Reliable Messaging

📤 Publish Event Persistence

Outgoing events are stored before being delivered to the broker.

Collection used:

  • PublishEvents

Stored information:

  • event type
  • destination
  • serialized payload
  • status
  • retries
  • timestamps

Example:

{
  "_id": "019e3223-200b-7308-baba-7a99740491c6",
  "EventType": "Test.Application.Kafka.MyKafkaPublishEvent",
  "EventDestination": "Kafka",
  "Value": "{\"Numerito\":28,\"EventId\":\"019e3223-1ff7-755d-8dc1-f5b804e9cfb2\",\"Timestamp\":\"2026-05-16T18:53:43.2871219+00:00\"}",
  "CreatedAt": {
    "$date": "2026-05-16T18:53:43.334Z"
  },
  "Status": "Processed",
  "RetryCount": 0
}

📥 Subscribe Event Persistence

Incoming broker events are also persisted before processing.

Collection used:

  • SubscribeEvents

Benefits:

  • reprocessing
  • auditing
  • decoupling reception and execution
  • resilience

Example:

{
  "_id": "019e3223-667b-7edd-822d-f883b9d932f4",
  "Topic": "kafka.event.test",
  "Value": "{\"Numerito\":28,\"EventId\":\"019e3223-1ff7-755d-8dc1-f5b804e9cfb2\",\"Timestamp\":\"2026-05-16T18:53:43.2871219+00:00\"}",
  "Headers": {
    "EventType": "Test.Application.Kafka.MyKafkaPublishEvent",
    "EventId": "019e3223-1ff7-755d-8dc1-f5b804e9cfb2",
    "Timestamp": "2026-05-16T18:53:43.2871219+00:00"
  },
  "ReceivedAt": {
    "$date": "2026-05-16T18:54:01.339Z"
  },
  "Status": "Pending",
  "RetryCount": 0,
  "SourceStorage": "MongoDb",
  "SourceEvent": "Kafka"
}

⚡ Main Features

  • MongoDB persistence
  • Event auditing
  • Retry support
  • Outbox-like storage
  • Inbox-like storage
  • Reliable event processing
  • Decoupled processing
  • Independent scopes
  • Asynchronous processing
  • Distributed systems support
  • Event tracking
  • Broker-independent persistence

🛠️ Implementation Details

Automatic indexes

Required indexes are automatically created during application startup.


Automatic collection creation

The MongoDB instance must allow automatic collection creation.


Broker-independent persistence

The storage layer is independent from the messaging broker used.

The storage implementation works with:

  • Kafka
  • RabbitMQ
  • Azure Service Bus
  • AWS SQS/SNS
  • custom providers

📋 Dependencies

  • MongoDB.Driver
  • YAMCqrs.EventBus.Core
Product Compatible and additional computed target framework versions.
.NET 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.

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
10.0.1 47 5/18/2026
10.0.0 48 5/17/2026