Quartz job stops triggering after a while in ASP.NET Core 6 and IIS

178 views Asked by At

I have a Quartz job in an ASP.NET Core 6 app that is hosted on an IIS server. It works flawlessly during the week when the site is getting a lot of traffic, but will invariably stop triggering during the weekend when there hasn't been a request in a while.

This is the implementation in the program.cs:

builder.Services.AddQuartz(q =>
{
    q.UseMicrosoftDependencyInjectionJobFactory();

    var jobKey = new JobKey("CsvExportJob");

    q.AddJob<CsvExportJob>(opts => opts.WithIdentity(jobKey));

    q.AddTrigger(opts => opts
        .ForJob(jobKey)
        .WithIdentity("CsvExportJob-trigger")
        .WithCronSchedule("0 0 0,6,12,18 ? * * *")
    );
});

builder.Services.AddQuartzServer(options =>
{
    options.WaitForJobsToComplete = true;
});

In my ASP.NET Core 5 app, I can easily bypass this problem by setting the IIS AppPool to AlwaysRunning so that the app doesn't start sleeping and keeps firing quartz jobs.

Using the same solution in ASP.NET Core 6 however does not seem to work as the jobs stop firing when traffic stops for a while.

Am I missing something? Did job handling changed in NET.6?

0

There are 0 answers