Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quartz.net repeat job at interval after job is completed

I am currently implementing Quartz.net in a simple application that should execute a piece of code every (for example) 5 seconds. Only now the code sometimes takes more than 5 seconds to complete.

At first I had the problem that the code was executed while the same code was still running, I fixed this by using the IStateFulJob interface instead of the IJob interface.

But what I would really like to accomplish is, that my job is executed 5 seconds AFTER the job is completed, not 5 seconds after my previous job is started.

I ofcourse could handle the event which is triggered when my listener 'hears' that the job is ready and re-schedule the job, but I was wondering if there isn't any standard functionality for this.

like image 815
Wim Haanstra Avatar asked Sep 19 '09 21:09

Wim Haanstra


People also ask

How do you schedule multiple jobs using Quartz?

If you want to schedule multiple jobs in your console application you can simply call Scheduler. ScheduleJob (IScheduler) passing the job and the trigger you've previously created: IJobDetail firstJob = JobBuilder. Create<FirstJob>() .

How many jobs can Quartz handle?

The actual number of jobs that can be running at any moment in time is limited by the size of the thread pool. If there are five threads in the pool, no more than five jobs can run at a time.

How do I Unschedule a Quartz job?

We can unschedule a Job by calling the unschedule() method of the Scheduler class and passing the TriggerKey . If the related job does not have any other triggers, and the job is not durable, then the job will also be deleted.

How does Quartz Scheduler work internally?

Quartz scheduler allows an enterprise to schedule a job at a specified date and time. It allows us to perform the operations to schedule or unschedule the jobs. It provides operations to start or stop or pause the scheduler. It also provides reminder services.


1 Answers

Currently there is no standard way to achieve this as Quartz.NET plays on the idea to have a predefined (calculated beforehand) fire time and polling for right time to trigger the work.

The way you described would be the easiest path. Either schedule from the the job the next execution or from the listener.

like image 70
Marko Lahma Avatar answered Oct 25 '22 01:10

Marko Lahma