NOBS.JobSystem.Hosting 1.1.1

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

NOBS.JobSystem

A lightweight, persistence-agnostic, dependency-injection friendly job scheduling system for .NET applications. It provides CRON-based scheduling, job chaining, manual triggering, and a persistent execution history with an optional Blazor-based monitoring UI.

Key Features

  • Fluent Configuration: A clean, expressive API for registering jobs and their dependencies.
  • Hybrid Configuration: Define job schedules and storage settings in appsettings.json while keeping job logic in code.
  • Pluggable Storage: Persist job history to SQL Server, MongoDB, SQLite, JSON files, or a custom provider.
  • Stable Job Identity: Use the [JobName] attribute to assign a persistent identifier to your jobs, preventing history loss when you refactor class names.
  • CRON Scheduling: Define recurring jobs using standard CRON expressions.
  • Job Chaining: Create powerful workflows by specifying continuation jobs on success or failure.
  • Global Error Handling: Configure a specific job to run whenever any unhandled exception occurs.
  • DI-First Design: Jobs are resolved from the service container, giving them full access to all registered application services.
  • Trimming and AOT Friendly: Designed to work out-of-the-box with trimmed and AOT-compiled applications.
  • Manual Triggering: Force any registered job to run immediately via the monitoring UI or programmatically.
  • Optional Monitoring UI: A clean, lightweight Blazor UI to monitor job statuses.

Packages

The system is distributed across multiple NuGet packages for modularity:

Package Description
NOBS.JobSystem The core library containing the job orchestrator and scheduling logic.
NOBS.JobSystem.Hosting A meta-package for easily installing and configuring the UI endpoint.
NOBS.JobSystem.UI The Blazor-based monitoring UI. (Typically consumed via the Hosting package)
NOBS.JobSystem.Stores.SqlServer Persistence provider for Microsoft SQL Server.
NOBS.JobSystem.Stores.MongoDb Persistence provider for MongoDB.
NOBS.JobSystem.Stores.SQLite Persistence provider for SQLite.
NOBS.JobSystem.Stores.JsonFile Persistence provider for a local JSON file.

Usage Guide

1. Configuration via AppSettings

You can manage your job schedules and storage settings externally using appsettings.json. This allows you to change schedules without recompiling the application.

appsettings.json

{
  "JobSystem": {
    "PollingFrequency": "00:01:00",
    "Jobs": {
      "report-processor": "0 2 * * *", 
      "db-cleanup": "0 4 * * 0"
    },
    "Storage": {
      "ConnectionString": "Server=.;Database=MyJobDb;Trusted_Connection=True;TrustServerCertificate=True;",
      "SchemaName": "scheduler",
      "HistoryTableName": "JobHistory",
      "PollingFrequency": "00:00:30"
    }
  }
}

Program.cs

using NOBS.JobSystem.Execution;
using NOBS.JobSystem.Stores.SqlServer;

var builder = WebApplication.CreateBuilder(args);

// Register Jobs
builder.Services.AddScoped<ProcessDailyReportsJob>();
builder.Services.AddScoped<DatabaseCleanupJob>();

// Add Job System with Configuration
builder.Services
    .AddJobSystem(builder.Configuration.GetSection("JobSystem"), registry =>
    {
        // Schedules defined in appsettings.json will override the code defaults.
        registry.AddJob<ProcessDailyReportsJob>("0 1 * * *");
        registry.AddJob<DatabaseCleanupJob>(); 
    })
    .UseSqlServer(builder.Configuration.GetSection("JobSystem:Storage"));

2. Fluent Configuration

Alternatively, you can configure everything in code.

builder.Services
    .AddJobSystem(registry =>
    {
        registry.AddJob<ProcessDailyReportsJob>("0 1 * * *")
            .OnSuccess<ArchiveOldReportsJob>()
            .OnError<ReportGenerationFailedJob>();

        registry.AddJob<ArchiveOldReportsJob>();
        registry.AddJob<ReportGenerationFailedJob>();
    })
    .UseJsonFile(options =>
    {
        options.FilePath = "Data/job_history.json"; 
        options.PollingFrequency = TimeSpan.FromSeconds(30);
    });

Defining Jobs

Jobs are simple classes that implement IJob.

[JobName("report-processor")]
public class ProcessDailyReportsJob(ILogger<ProcessDailyReportsJob> logger) : IJob
{
    public async Task<JobExecutionResult> ExecuteAsync(CancellationToken cancellationToken)
    {
        logger.LogInformation("Starting daily report generation...");
        // Logic...
        return JobExecutionResult.Success();
    }
}

Building From Source

To build the project from source, clone the repository and run the .NET build command from the root directory.

git clone https://github.com/scippo97sensibleproductions/NOBS.JobSystem.git
cd NOBS.JobSystem
dotnet build -c Release

Contributing

Contributions are welcome. Please follow these standard steps:

  1. Fork the repository.
  2. Create a new feature branch (git checkout -b feature/your-feature-name).
  3. Commit your changes (git commit -m 'Add some feature').
  4. Push to the branch (git push origin feature/your-feature-name).
  5. Open a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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 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
1.1.1 351 11/25/2025
1.1.0 343 11/10/2025
1.0.9 289 11/10/2025
1.0.8 296 11/10/2025
1.0.7 296 9/25/2025
1.0.6 235 9/25/2025
1.0.5 232 9/25/2025
1.0.4 237 9/25/2025
1.0.1 243 9/24/2025
1.0.0 246 9/24/2025