EP 3 : Schedule Jobs with Quartz.NET
There are many ways to schedule background jobs, but two are particularly well-known. Quartz and Hangfire. I talked about Hangfire in a recent LinkedIn post. Today we are going to learn about Quartz.
Quartz.NET is used for scheduling jobs with some additional features over Hangfire. CRON triggers, calendar events, and simple events are all supported.
How to use it?
Install Packages
Create Job
Configure Program.cs
Step 1: Install Packages
Install the following packages from the Nuget Package Manager
Microsoft.Data
.SqlClient
Quartz
Quartz.Serialization.Json
Step 2: Create Job
Step 3: Configure Program.cs
I have created an extension method for IServiceCollections and called it in Program.cs
await
builder.Services
.ConfigureQuartzScheduler();
If we want to use our storage then we can configure SQL otherwise it will automatically use our RAM Job Store.
Using With Identity to group jobs while creating the jobs and triggering them.
Where I have used
WithSimpleSchedule
you can use Calendar/CRON as per your needs
There are 3 ways you can help me in growing:
Subscribe to my YouTube Channel
Subscribe to my Weekly .NET Newsletter of C#/.NET
Download my eBook at Gum Road which contains 30+ .NET Tips