Skip to content

Overview

NexJob decouples job scheduling from persistence through a single IStorageProvider abstraction. Every backend — from the zero-config in-memory default to a production-grade PostgreSQL cluster — plugs in through the same registration pattern: call the provider's registration method before AddNexJob(), and NexJob picks it up automatically. This page explains what each backend offers so you can match the right one to your workload.

Provider comparison

Provider NuGet package Recommended for Key notes
InMemory (built-in) Development, unit tests Zero dependencies; data lost on restart
PostgreSQL NexJob.Postgres Production (relational) Full ACID, FOR UPDATE SKIP LOCKED, read replica support, vectorized batch ack
SQL Server NexJob.SqlServer Production (relational) Full ACID, UPDLOCK READPAST, read replica support, vectorized batch ack
Redis NexJob.Redis Production (high-throughput) Microsecond dispatch, Lua-script batching, distributed throttle support
MongoDB NexJob.MongoDB Production (document) FindOneAndUpdate atomics, UpdateManyAsync batch ack, auto index creation

Storage interfaces

IStorageProvider is a composed interface built from three focused contracts. All built-in providers implement all three — you never need to register them separately unless you want to customize a specific concern.

Interface Responsibility Inject directly when you need…
IJobStorage Job enqueue, dequeue, and worker coordination Custom job execution or worker logic
IRecurringStorage Recurring job scheduling and lease management Custom recurring job scheduling logic
IDashboardStorage Dashboard queries, job lists, and metrics Custom reporting, admin tooling, or a read replica

For most applications, inject IStorageProvider to access all three concerns through one dependency. When you only need one aspect — for example, pointing dashboard reads at a read replica — override just IDashboardStorage without touching the others.

Optional capabilities for a custom provider

A storage you write yourself implements the three interfaces above. One more contract is optional: IOrphanedJobReporter. Its RequeueOrphanedJobsAndReportAsync does what RequeueOrphanedJobsAsync does and returns the ids of the jobs it moved to Failed because they had no attempts left, so the orphan watcher can call the dead-letter handler and forwarders for them. A provider that does not implement it still works: those jobs become Failed, but nothing is called for them. A job must be reported by the call that moved it and by no other, so that several nodes never dead-letter the same job twice. See Delivery Guarantees.

Programmatic job control

IJobControlService pauses and resumes queues, requeues or deletes jobs and resets a circuit breaker from code. See Runtime Control.

InMemory (default)

The InMemory provider is built into the NexJob core package and requires no additional dependencies. It is the default when you call AddNexJob() without any prior storage registration.

// Implicit — InMemory is used when no storage provider is registered first
builder.Services.AddNexJob();

// Explicit, same result
builder.Services.AddNexJob(options => options.UseInMemory());

Warning

InMemory is not suitable for production. All jobs are held in process memory and are permanently lost when the application restarts or crashes. Use it for local development and automated tests only.

Choose your provider

  • PostgreSQL

    Full ACID transactions, FOR UPDATE SKIP LOCKED concurrency, dashboard read replica support, and vectorized batch acknowledgment.

  • SQL Server

    Full ACID transactions, UPDLOCK READPAST row locking, Azure SQL read replica support, and vectorized batch acknowledgment.

  • Redis

    Microsecond-latency dispatch, server-side Lua script batching, sorted-set priority queues, and cluster-wide distributed throttling.

  • MongoDB

    Document-model storage, FindOneAndUpdate atomic transitions, UpdateManyAsync batch acknowledgment, and automatic index creation.

Try it

The NexJob.Sample.Providers sample is the same small app on InMemory, PostgreSQL, SQL Server, Redis or MongoDB, chosen by Sample:Provider, so you can compare providers without changing code.