Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quartz scheduler: Register multiiple jobs under same trigger

I'm new to the Quartz scheduler. I had few queries and hope someone give a hand here. Thanks a lot!

First of all, let me share with you on my way to organize the jobs and triggers in single Scheduler:

  1. One trigger group, many triggers with unique name

  2. Many job groups, many jobs with unique name inside one group

  3. One job group may associate with one trigger so that all jobs under this group will be fired at the same time

I think this organization is quite normal in scheduler software. However, I only found references to register same job with multiple triggers. Even though, I still thought to register many jobs with the same trigger is achievable logically.

Following is my own logic to achieve the goal:

  1. Job A be created, Trigger A be created, call function scheduleJob(JobA, TriggerA) to register Job A with Scheduler firstly

  2. Job B be created, get Trigger A from Scheduler based on its unique name, call function scheduleJob(JobB, TriggerA) to register Job B with Scheduler later

Therefore, refer to my own logic, I had two queries:

  1. Is it possible to implement getting Trigger A from Scheduler based on its name ?

  2. Is it a correct way to register multiple jobs with same trigger by using scheduleJob() function again and again ?

like image 669
ShadowScorpion Avatar asked Feb 26 '13 10:02

ShadowScorpion


People also ask

How to pass multiple jobs to spring quartz scheduler?

We can pass multiple jobs to spring quartz scheduler along with multiple triggers or single same trigger. Need to create multiple Job classes that implements Job interface. Create multiple Triggers by passing different scheduling times.

Is it possible to trigger multiple jobs in a single job?

P.S In Quartz, one trigger for multiple jobs is not possible. (Correct me if this is wrong.) 1. Quartz APIs Create 3 Quartz’s jobs, JobA, JobB and JobC.

How do I schedule a job in a trigger?

When you wish to schedule a job, you instantiate a trigger and 'tune' its properties to provide the scheduling you wish to have. Triggers may also have a JobDataMap associated with them - this is useful to passing parameters to a Job that are specific to the firings of the trigger.

How do I use the ischeduler interface?

Once created the IScheduler interface can be used add, remove, and list Jobs and Triggers, and perform other scheduling-related operations (such as pausing a trigger). However, the Scheduler will not actually act on any triggers (execute jobs) until it has been started with the Start () method, as shown in Lesson 1.


1 Answers

No, a job can have many triggers relating to it, but a trigger can only relate to one job. Though you can get something of the effect you're after if you use a job/trigger listener and schedule triggers to fire other jobs immediately when the one trigger fires.

You can set up multiple identical triggers, one for each job.

like image 91
Jeevan Patil Avatar answered Oct 12 '22 19:10

Jeevan Patil