JobFlow.NET is a pre-release .NET library for one-time and delayed background jobs backed by SQL Server.
Status: pre-release and under active development. JobFlow uses renewable SQL Server job leases and has automated SQL integration coverage. It still provides at-least-once delivery: job handlers must be safe to run more than once. Do not use it in production yet.
The project explores a small, explicit job-scheduling model:
- A job implements
IJoband receives an optional payload plus a cancellation token. - SQL Server stores jobs and atomically claims ready work for competing workers.
- A hosted dispatcher resolves a fresh job instance from dependency injection for each execution.
- Failed jobs are retried with exponential backoff until their retry limit is reached.
- Each claim has a lease token. Only the worker holding the current, unexpired token can complete, fail, or renew its job.
The SQL Server store uses UPDLOCK and READPAST to make claiming a job a single database operation. An expired lease can be reclaimed by another worker. This protects the queue from a crashed worker, but it also means an external side effect (for example, charging a card) must use its own idempotency key.
The first public release will be a pre-release package:
JobFlow.Core— job contracts, scheduling API, and hosted dispatcher.JobFlow.SqlServer— SQL Server store and dependency-injection registration.
dotnet add package JobFlow.SqlServer --prereleaseRegister the SQL Server store and your job type when configuring the host:
using JobFlow.Core;
using JobFlow.SqlServer;
using Microsoft.Extensions.DependencyInjection;
builder.Services.UseSqlServerJobStore(
"Server=localhost,1433;Database=JobFlow;User Id=sa;Password=your-password;TrustServerCertificate=True;");
builder.Services.AddTransient<PrintJob>();Schedule work through JobScheduler:
var scheduler = host.Services.GetRequiredService<JobScheduler>();
await scheduler.EnqueueAsync<PrintJob>("hello");
await scheduler.ScheduleAsync<PrintJob>(TimeSpan.FromMinutes(5), "run later");PrintJob implements IJob:
public sealed class PrintJob : IJob
{
public Task ExecuteAsync(string? payload, CancellationToken ct)
{
Console.WriteLine(payload);
return Task.CompletedTask;
}
}The included SQL Server registration creates or upgrades the dbo.Jobs schema when the application starts.
For the details behind the quick start, read the documentation index:
src/
JobFlow.Core/ Job contracts, records, and dispatcher
JobFlow.SqlServer/ SQL Server-backed job store and schema script
- .NET SDK 9.0 or later to build the full solution.
- Docker Desktop to run the SQL Server integration tests. The tests start their own disposable SQL Server container.
dotnet restore JobFlow.sln
dotnet build JobFlow.sln --configuration Release --no-restore
dotnet test JobFlow.sln --configuration Release --no-buildThe test suite exercises real SQL Server behavior through Testcontainers. The sample application in samples/JobFlow.Sample shows basic registration and scheduling.
- Prove competing-consumer behavior with multiple worker instances.
- Add recurring jobs using cron expressions.
- Add release automation and publish a preview package.
- Consider additional storage adapters only after the SQL Server behavior is proven.
Please read CONTRIBUTING.md before opening a pull request. See SECURITY.md for private vulnerability reporting guidance and SUPPORT.md for questions.
Licensed under the MIT License.