开发者

How can I set priorities to quartz trigger?

I am using Quar开发者_StackOverflow社区tz 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?


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 trigger


Triggers have a 'priority' property on them. Just set the property accordingly as the triggers are created, or use the api to retrieve the triggers, set the priorities, and reschedule them.

If two or more triggers have the same fire time and same priority, one will be randomly chosen for firing first (what else could the ordering be based on?).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜