NexJob.MongoDB 5.6.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package NexJob.MongoDB --version 5.6.2
                    
NuGet\Install-Package NexJob.MongoDB -Version 5.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="NexJob.MongoDB" Version="5.6.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NexJob.MongoDB" Version="5.6.2" />
                    
Directory.Packages.props
<PackageReference Include="NexJob.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 NexJob.MongoDB --version 5.6.2
                    
#r "nuget: NexJob.MongoDB, 5.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 NexJob.MongoDB@5.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=NexJob.MongoDB&version=5.6.2
                    
Install as a Cake Addin
#tool nuget:?package=NexJob.MongoDB&version=5.6.2
                    
Install as a Cake Tool

NexJob.MongoDB

MongoDB storage provider for NexJob — the background job scheduler for .NET 8+.

Backed by the official MongoDB.Driver, this provider uses FindOneAndUpdateAsync with atomic condition filters for concurrency-safe, lock-free job claiming across distributed workers.


Installation

dotnet add package NexJob.MongoDB

Quick Start

Register MongoDB storage in your dependency injection container before calling AddNexJob():

using NexJob;
using NexJob.MongoDB;

var builder = WebApplication.CreateBuilder(args);

// 1. Register MongoDB storage
builder.Services.AddNexJobMongoDB(
    connectionString: builder.Configuration.GetConnectionString("MongoConnection")!,
    databaseName: "nexjob");

// 2. Register NexJob core services
builder.Services.AddNexJob(options =>
{
    options.Workers = 10;
    options.Queues = ["default", "critical"];
});

Or provide a pre-configured IMongoDatabase:

var client = new MongoClient("mongodb://localhost:27017");
var database = client.GetDatabase("nexjob");

builder.Services.AddNexJobMongoDB(database);

High-Throughput Batch Processing

For heavy ingestion workloads, enable batch processing to group job reservations and vectorized acknowledgments using UpdateManyAsync:

builder.Services.AddNexJobMongoDB(
    connectionString: builder.Configuration.GetConnectionString("MongoConnection")!,
    databaseName: "nexjob");

builder.Services.AddNexJob(options =>
{
    // Workers dynamically batch fetches to keep all idle slots busy
    options.Workers = 30;
    options.PollingInterval = TimeSpan.FromMilliseconds(20);

    // Commit successful jobs in asynchronous batches via UpdateManyAsync ($in: [ids])
    options.EnableBatchAcknowledgment = true;
});

Features

  • High-Throughput Batching: Atomic batch claim and vectorized batch acknowledgment (UpdateManyAsync by ID set).
  • Atomic State Transitions: Uses MongoDB FindOneAndUpdate with optimistic filter criteria (status: Enqueued) to prevent race conditions across multiple nodes without global locks.
  • Automatic Index Creation: Automatically builds compound and unique indexes on initialization for queues, priority, idempotency keys, and scheduled timestamps.
  • Document-Oriented Storage: Flexible document schema for job arguments, execution metadata, and logs.
  • Distributed Recurring Locks: Manages cron recurring job execution safely across replica sets using atomic collection locks (nexjob_recurring_locks).
  • Runtime Settings Store: Persists dynamic queue limits and pause status in MongoDB.
  • Scoped Date Serialization: DateTimeOffset is stored as a UTC ISO 8601 string for NexJob documents only; NexJob no longer registers a global serializer that would change how your own types are stored. If your application relied on the old global registration, pass keepLegacyGlobalDateTimeOffsetSerializer: true to AddNexJobMongoDB for one release.

Collections

The provider automatically manages the following collections in the target database:

Collection Purpose
nexjob_jobs Job documents, input parameters, state transitions, retry attempts, and logs
nexjob_recurring_jobs Recurring cron job schedules and execution tracking
nexjob_recurring_locks Distributed locks for recurring job scheduling
nexjob_servers Worker node heartbeats and cluster discovery
nexjob_settings Dynamic queue configurations and runtime controls

Connection String Example

{
  "ConnectionStrings": {
    "MongoConnection": "mongodb://user:secret@localhost:27017/?authSource=admin&replicaSet=rs0"
  }
}
Product 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 was computed.  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

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
6.7.0 83 10/19/2026
6.6.0 89 10/18/2026
6.5.1 92 10/17/2026
6.5.0 90 10/17/2026
6.4.0 92 10/16/2026
6.3.0 79 10/12/2026
6.2.1 85 10/11/2026
6.2.0 95 10/10/2026
6.1.0 87 10/10/2026
6.0.0 90 10/9/2026
5.10.0 95 10/8/2026
5.9.0 93 10/5/2026
5.8.0 100 10/4/2026
5.7.0 91 10/1/2026
5.6.2 99 10/1/2026
5.6.1 102 9/30/2026
5.6.0 88 9/30/2026
5.5.0 97 9/25/2026
5.4.1 95 9/24/2026
5.4.0 98 9/24/2026
Loading failed