I am using Quartz Scheduler and there are 15 jobs. For each job there is one trigger. I want to set priority for each trigger. I can set low priority as 10 and high priority as 1. But as I am having 15 triggers for 15 jobs I need different priority for each trigger. e.g trigger1 will have priority 10, trigger2 will have priority 9. In this way I need to give same priority for two triggers.
So if two triggers with same priority will get execute at same time then which trigger will execute first?
Can anyone tell me how I can set different priorities for different triggers?
build(); // Tell quartz to schedule the job using our trigger sched. scheduleJob(job, trigger); The block of code that builds the job definition is using methods that were statically imported from the JobBuilder class.
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.
A misfire occurs if a persistent trigger “misses” its firing time because of the scheduler being shutdown, or because there are no available threads in Quartz's thread pool for executing the job. The different trigger types have different misfire instructions available to them.
Example 3 - Cron-based TriggersStart up the Quartz Scheduler. Schedule several jobs using various features of CronTrigger. Wait for 300 seconds (5 minutes) to give Quartz a chance to run the jobs. Shut down the Scheduler.
Trigger have a property called WithPriority
which takes a integer value. When multiple triggers are fired at the same time the scheduler will fire the trigger with the highest priority first. And if the two triggers have same priority then either trigger will get fired.
.WithPriority(15)
will run first.WithPriority(1)
will be the last triggerIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With