NexJob.MongoDB
5.7.0
See the version list below for details.
dotnet add package NexJob.MongoDB --version 5.7.0
NuGet\Install-Package NexJob.MongoDB -Version 5.7.0
<PackageReference Include="NexJob.MongoDB" Version="5.7.0" />
<PackageVersion Include="NexJob.MongoDB" Version="5.7.0" />
<PackageReference Include="NexJob.MongoDB" />
paket add NexJob.MongoDB --version 5.7.0
#r "nuget: NexJob.MongoDB, 5.7.0"
#:package NexJob.MongoDB@5.7.0
#addin nuget:?package=NexJob.MongoDB&version=5.7.0
#tool nuget:?package=NexJob.MongoDB&version=5.7.0
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 (
UpdateManyAsyncby ID set). - Atomic State Transitions: Uses MongoDB
FindOneAndUpdatewith 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:
DateTimeOffsetis 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, passkeepLegacyGlobalDateTimeOffsetSerializer: truetoAddNexJobMongoDBfor 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 | 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 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. |
-
net8.0
- MongoDB.Driver (>= 2.30.0)
- NexJob (>= 5.7.0)
- SharpCompress (>= 0.48.0)
- Snappier (>= 1.3.1)
- System.Text.Encodings.Web (>= 8.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 |
|---|---|---|
| 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 |