Muonroi.BackgroundJobs.Quartz
1.0.0-alpha.16
dotnet add package Muonroi.BackgroundJobs.Quartz --version 1.0.0-alpha.16
NuGet\Install-Package Muonroi.BackgroundJobs.Quartz -Version 1.0.0-alpha.16
<PackageReference Include="Muonroi.BackgroundJobs.Quartz" Version="1.0.0-alpha.16" />
<PackageVersion Include="Muonroi.BackgroundJobs.Quartz" Version="1.0.0-alpha.16" />
<PackageReference Include="Muonroi.BackgroundJobs.Quartz" />
paket add Muonroi.BackgroundJobs.Quartz --version 1.0.0-alpha.16
#r "nuget: Muonroi.BackgroundJobs.Quartz, 1.0.0-alpha.16"
#:package Muonroi.BackgroundJobs.Quartz@1.0.0-alpha.16
#addin nuget:?package=Muonroi.BackgroundJobs.Quartz&version=1.0.0-alpha.16&prerelease
#tool nuget:?package=Muonroi.BackgroundJobs.Quartz&version=1.0.0-alpha.16&prerelease
Muonroi.BackgroundJobs.Quartz
Quartz.NET provider for the Muonroi background-jobs abstraction — swap in Quartz with a single config change, no code rewrites.
This package wires Quartz.NET into the IBackgroundJobScheduler abstraction defined by Muonroi.BackgroundJobs.Abstractions. It registers a Quartz hosted service, a global QuartzContextJobListener that restores Muonroi execution context (tenant ID, user, correlation ID, access token) before each job runs, and an IBackgroundJobScheduler scoped service. The assembly uses a [ModuleInitializer] to self-register the JobType.Quartz provider with BackgroundJobHandler at load time — no manual wiring beyond adding the package reference.
Note: Expression-based scheduling (
Enqueue<T>,Schedule<T>,AddOrUpdateRecurring<T>) is not yet supported in this provider. Quartz jobs must be class-based (implementIJob). For expression-based scheduling useMuonroi.BackgroundJobs.Hangfireinstead.
Installation
dotnet add package Muonroi.BackgroundJobs.Quartz --prerelease
Quick Start
Add the configuration section to appsettings.json:
{
"BackgroundJobConfigs": {
"JobType": "Quartz",
"ConnectionString": null
}
}
Register in Program.cs:
// Reference Muonroi.BackgroundJobs.Quartz — its [ModuleInitializer] registers
// the Quartz provider with BackgroundJobHandler automatically on assembly load.
using Muonroi.BackgroundJobs.Abstractions;
builder.Services.AddBackgroundJobs(builder.Configuration);
Define a class-based job (Quartz IJob):
using Quartz;
public sealed class DataCleanupJob : IJob
{
public Task Execute(IJobExecutionContext context)
{
// Muonroi execution context (tenant, user, correlationId) is already
// restored by QuartzContextJobListener before this method is called.
return Task.CompletedTask;
}
}
Schedule the job at startup using the native Quartz API (inject ISchedulerFactory):
IScheduler scheduler = await schedulerFactory.GetScheduler();
IJobDetail job = JobBuilder.Create<DataCleanupJob>()
.WithIdentity("data-cleanup")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithCronSchedule("0 2 * * ?")
.Build();
await scheduler.ScheduleJob(job, trigger);
Features
- Registers
Quartz,Quartz.Extensions.DependencyInjection, andQuartz.Extensions.Hostingwith a singleAddBackgroundJobscall. - Validates that
BackgroundJobConfigs:JobTypeisQuartz; throwsMConfigurationExceptionif misconfigured. QuartzContextJobListenerrestores the full MuonroiSystemExecutionContext(tenant ID, user ID, username, correlation ID, access token, API key, permissions) for every job execution viaIJobExecutionContext.MergedJobDataMap.- Quartz hosted service is configured with
WaitForJobsToComplete = truefor graceful shutdown. - AOT-safe: provider registration uses a compile-time delegate, no reflection.
- Self-registering: merely adding the package reference causes
[ModuleInitializer]to enroll theJobType.Quartzprovider — no extra DI calls needed.
Configuration
BackgroundJobConfigs options
| Property | Type | Default | Description |
|---|---|---|---|
JobType |
JobType |
Quartz |
Must be Quartz for this package. |
ConnectionString |
string? |
null |
Optional; passed through for persistence store setup if needed. |
BackgroundJobConfigs.SectionName is the constant "BackgroundJobConfigs".
API Reference
| Type | Purpose |
|---|---|
BackgroundJobHandler (static) |
Extension class; exposes AddBackgroundJobs(IServiceCollection, IConfiguration) |
BackgroundJobConfigs |
Options POCO bound from "BackgroundJobConfigs" config section |
QuartzContextJobListener |
IJobListener that restores Muonroi SystemExecutionContext before each job |
QuartzJobScheduler |
Scoped IBackgroundJobScheduler implementation (class-based jobs only) |
Samples
- Quickstart.BackgroundJobs — demonstrates provider selection (Hangfire vs Quartz via
JobTypeconfig), class-based job definitions, andIBackgroundJobSchedulerusage.
Compatibility
- Target framework:
net8.0 - License: Commercial — requires activation
Related Packages
Muonroi.BackgroundJobs.Abstractions—IBackgroundJobScheduler,JobType, and shared contractsMuonroi.BackgroundJobs.Hangfire— Hangfire provider; supports expression-based scheduling
License
This package is distributed under a commercial license. A valid Muonroi license is required for production use. See LICENSE-COMMERCIAL for terms.
| 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
- Muonroi.BackgroundJobs.Abstractions (>= 1.0.0-alpha.16)
- Muonroi.Core.Abstractions (>= 1.0.0-alpha.16)
- Quartz (>= 3.15.0)
- Quartz.Extensions.DependencyInjection (>= 3.15.0)
- Quartz.Extensions.Hosting (>= 3.15.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Muonroi.BackgroundJobs.Quartz:
| Package | Downloads |
|---|---|
|
Muonroi.BuildingBlock.All
Metapackage for Muonroi Building Block - Includes all sub-packages for a complete infrastructure setup. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0-alpha.16 | 52 | 6/22/2026 |
| 1.0.0-alpha.15 | 79 | 5/31/2026 |
| 1.0.0-alpha.14 | 75 | 5/15/2026 |
| 1.0.0-alpha.13 | 74 | 5/2/2026 |
| 1.0.0-alpha.12 | 78 | 4/2/2026 |
| 1.0.0-alpha.11 | 129 | 4/2/2026 |
| 1.0.0-alpha.8 | 158 | 3/28/2026 |
| 1.0.0-alpha.1 | 66 | 3/8/2026 |