Reputation: 331
i have some jobs to fire by three triggers(four jobs to every trigger) i want one specified job to fire always FIRST, rest can fire at random order. should i implement different trigger? is there a way to do something with priorities? i already fire them in one thread
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 1
and
newTrigger().withSchedule(
CronScheduleBuilder.cronSchedule(exp))
.withPriority(getPriorityForOperation(cronOperation))
.build();
where priority for first job is different than for the rest, but anyway it runs at random order
Upvotes: 3
Views: 1670
Reputation: 331
i misunderstood priorities in Quartz. it is for Triggers, not for jobs. to fire jobs at specified order we need to use
JobChainingJobListener chain;
chain.addJobChainLink(dailyJob.getKey(), jobDetail.getKey());
where jobDetail is in my example Monthly, Quarterly and Annual. thank you for your help.
Upvotes: 1
Reputation: 273
Sometimes, when you have many Triggers (or few worker threads in your Quartz thread pool), Quartz may not have enough resources to immediately fire all of the Triggers that are scheduled to fire at the same time. In this case, you may want to control which of your Triggers get first crack at the available Quartz worker threads. For this purpose, you can set the priority property on a Trigger. If N Triggers are to fire at the same time, but there are only Z worker threads currently available, then the first Z Triggers with the highest priority will be executed first. If you do not set a priority on a Trigger, then it will use the default priority of 5. Any integer value is allowed for priority, positive or negative.
Upvotes: 3