Home Quartz.NET fires same job multiple times when adding multiple different jobs
Reply: 0

Quartz.NET fires same job multiple times when adding multiple different jobs

user1961 Published in August 15, 2018, 11:16 am

I have Quartz.NET installed and running in my ASP.NET MVC app. It's working fine for 1 job but as soon as I add in a second job all of the jobs fire 2-3 times each. Here is the code I have to schedule the jobs:

private void ScheduleAll(HttpApplication context)
    ISchedulerFactory schedFact = new StdSchedulerFactory();
    IScheduler sched = schedFact.GetScheduler();

    // Schedule All Daily Emails
    IJobDetail dailyEmailJob = JobBuilder.Create<DailyEmails>().WithIdentity("DailyEmailJob", "DailyEmailGroup").Build();
    dailyEmailJob.JobDataMap["context"] = HttpContext.Current;
    ITrigger dailyEmailTrigger = TriggerBuilder.Create().WithDailyTimeIntervalSchedule(s => s.WithIntervalInHours(24).OnEveryDay().StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(3, 0))).Build();
    sched.ScheduleJob(dailyEmailJob, dailyEmailTrigger);

    // Nightly Maintenance
    IJobDetail scheduledMaintenanceJob = JobBuilder.Create<ScheduledMaintenance>().WithIdentity("ScheduledMaintenanceJob", "ScheduledMaintenanceGroup").Build();
    scheduledMaintenanceJob.JobDataMap["context"] = HttpContext.Current;
    ITrigger scheduledMaintenanceTrigger = TriggerBuilder.Create().WithDailyTimeIntervalSchedule(s => s.WithIntervalInHours(24).OnEveryDay().StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(1, 0))).Build();
    sched.ScheduleJob(scheduledMaintenanceJob, scheduledMaintenanceTrigger);

It seems to be running 3 times on Mondays and 1 time the other days of the week. I used to have it configured to run certain jobs on Mondays and others every day of the week but that would also run the jobs multiple times so I stopped that and began running the job every day and using c# to determine the day of the week and thus which code to execute.

Could it be that the jobs are queuing up on the server somehow from past schedules?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.305304 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO