Back to Quartznet

Quartz.AspNetCore

src/Quartz.AspNetCore/README.md

3.19.01.6 KB
Original Source

Quartz.AspNetCore

Quartz.AspNetCore provides ASP.NET Core hosted service integration for Quartz.NET, running a scheduler that starts and stops with the application lifetime.

Tip: If you only need the generic host, Quartz.Extensions.Hosting may be enough.

Installation

shell
dotnet add package Quartz.AspNetCore

Usage

Register the scheduler with AddQuartzServer:

csharp
services.AddQuartz(q =>
{
    // scheduler, job and trigger configuration
});

services.AddQuartzServer(options =>
{
    // wait for jobs to complete gracefully on shutdown
    options.WaitForJobsToComplete = true;
});

See the Microsoft DI integration docs for configuring jobs and triggers.

Health checks

On target frameworks with health check support, AddQuartzServer also registers an ASP.NET Core health check named quartz-scheduler that reports unhealthy when the scheduler is not running or cannot reach its store. Attach tags to filter it into separate liveness/readiness probes:

csharp
services.AddQuartzServer(
    options => options.WaitForJobsToComplete = true,
    healthCheckTags: ["ready", "live"]);

Documentation

šŸ“– Full documentation: https://www.quartz-scheduler.net/documentation/quartz-3.x/packages/aspnet-core-integration.html