I am using Quartz Jobs to make background data processing in my ASP Net Core project. I found that when i am using valid Cron Expressions they not triggered and there are no errors or warnings in logs / console.
My jobs configuration looks like:
private void ConfigureRegularJobs(IServiceCollection services)
{
services.AddQuartz(quartz =>
{
quartz.UseMicrosoftDependencyInjectionJobFactory();
quartz.AddJob<SpectraIndexerJob>(job => job.WithIdentity(nameof(SpectraIndexerJob)));
//todo: umv: move in config (every 3 hours)
quartz.AddTrigger(trigger => trigger.ForJob(nameof(SpectraIndexerJob)) .WithCronSchedule(_config.DefaultJobsSettings.DefaultSpectraIndexerSchedule));
// other jobs ....
});
services.AddQuartzHostedService(options => options.WaitForJobsToComplete = true);
}
My cron expressions are valid, they were generated using online generator: https://www.freeformatter.com/cron-expression-generator-quartz.html
I.e. for upper mentioned job configuration i pass "0/30 0 0 ? * * *" as CRON-expression.
How to find reason of why my Jobs are not trigger?
Upd:
- My Logs configuration is:
"Logging": {
"LogLevel": {
"Default": "Debug",
"Microsoft": "Debug",
"Microsoft.Hosting.Lifetime": "Debug",
"Quartz.Core.QuartzScheduler": "Debug"
}
},
- If i replace
WithCronSchedulewith
.WithSimpleSchedule(x => x.WithIntervalInMinutes(1)
.RepeatForever()));
everything works fine.
- My logs from app including quartz logs:
dbug: Microsoft.AspNetCore.Hosting.Diagnostics[3]
Hosting starting
dbug: Quartz.Simpl.TaskSchedulingThreadPool[0]
TaskSchedulingThreadPool configured with max concurrency of 10 and TaskScheduler ThreadPoolTaskScheduler.
info: Quartz.Core.SchedulerSignalerImpl[0]
Initialized Scheduler Signaller of type: Quartz.Core.SchedulerSignalerImpl
info: Quartz.Core.QuartzScheduler[0]
Quartz Scheduler created
info: Quartz.Core.QuartzScheduler[0]
JobFactory set to: Quartz.Simpl.MicrosoftDependencyInjectionJobFactory
info: Quartz.Simpl.RAMJobStore[0]
RAMJobStore initialized.
info: Quartz.Core.QuartzScheduler[0]
Scheduler meta-data: Quartz Scheduler (v3.4.0.0) 'Wissance.MossbauerLab.Watcher.ead4e265-d489-455e-b654-4ca7d9abc034' with instanceId 'ead4e265-d489-455e-b654-4ca7d9abc034'
Scheduler class: 'Quartz.Core.QuartzScheduler' - running locally.
NOT STARTED.
Currently in standby mode.
Number of jobs executed: 0
Using thread pool 'Quartz.Simpl.DefaultThreadPool' - with 10 threads.
Using job-store 'Quartz.Simpl.RAMJobStore' - which does not support persistence. and is not clustered.
info: Quartz.Impl.StdSchedulerFactory[0]
Quartz scheduler 'Wissance.MossbauerLab.Watcher.ead4e265-d489-455e-b654-4ca7d9abc034' initialized
info: Quartz.Impl.StdSchedulerFactory[0]
Quartz scheduler version: 3.4.0.0
dbug: Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer[2]
Failed to locate the development https certificate at '(null)'.
warn: Microsoft.AspNetCore.Server.Kestrel[0]
Overriding address(es) 'https://localhost:5001/, http://localhost:5000/'. Binding to endpoints defined in UseKestrel() instead.
dbug: Microsoft.AspNetCore.Hosting.Diagnostics[4]
Hosting started
dbug: Microsoft.AspNetCore.Hosting.Diagnostics[0]
Loaded hosting startup assembly Wissance.MossbauerLab.Watcher.Web
Hosting environment: Development
Content root path: C:\Users\michael\Projects\Wissance\LabWatcher\Wissance.MossbauerLab.Watcher\Wissance.MossbauerLab.Watcher
Now listening on: http://localhost:7890
Application started. Press Ctrl+C to shut down.
info: Quartz.Core.QuartzScheduler[0]
Scheduler Wissance.MossbauerLab.Watcher.ead4e265-d489-455e-b654-4ca7d9abc034_$_ead4e265-d489-455e-b654-4ca7d9abc034 started.
dbug: Quartz.Core.QuartzSchedulerThread[0]
Batch acquisition of 0 triggers