Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quartz: triggering multiple jobs

In Quarts, can I use a single trigger to schedule multiple jobs, so that all the jobs gets executed in parallel. What is the best way to do this.

Example, every hour execute Jobs j1, j2, ..., jn in parallel. Assuming that there is no dependency between the jobs.

like image 553
Phanindra Avatar asked May 05 '10 14:05

Phanindra


People also ask

How do you trigger multiple jobs in quartz scheduler?

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 you trigger a quartz job?

Create a Scheduler with a single worker thread. Schedule three Triggers with different priorities that fire the first time at the same time, and a second time at staggered intervals. Start up the Quartz Scheduler. Wait for 30 seconds to give Quartz a chance to fire the Triggers.

How do you reschedule a quartz job?

rescheduleJob. Remove (delete) the Trigger with the given key, and store the new given one - which must be associated with the same job (the new trigger must have the job name & group specified) - however, the new trigger need not have the same name as the old trigger. newTrigger - The new Trigger to be stored.


2 Answers

You can't associate multiple jobs with the same trigger (a given job can have multiple triggers, but not vice versa), but you can set up multiple identical triggers, one for each job.

In order to get them running in parallel, you need to ensure that Quartz's thread pool has enough capacity to do so. See here for the config options for the thread pool.

like image 111
skaffman Avatar answered Sep 29 '22 02:09

skaffman


You can build a trigger job that triggers the other jobs. Make it configurable by using the JobMap properties, and you can reuse the class for triggering an arbitrary set of jobs (and maybe executing the first for yourself).

like image 29
Daniel Avatar answered Sep 29 '22 04:09

Daniel