Intro Quartz Versus FixedRate Versus FixedDelay

Intro Quartz Versus FixedRate Versus FixedDelay

這篇介紹Quartz Versus FixedRate Versus FixedDelay.

Compare

1
2
3
4
5
6
7
8
9
10
11
12
13
在使用quartz做排程時,
要注意在job class的定義上必須加上
@DisallowConcurrentExecution的annotation,才不會一直重複執行。

以每秒排程為例
有加@DisallowConcurrentExecution -> 會等該job執行完才會進行下一個schedule
沒加@DisallowConcurrentExecution -> 不會等該job執行完,在每秒繼續執行下一個schedule

quartz和ScheduleAtFixedRate or ScheduleWithFixedDelay建議使用情境:
1.quartz用在固定時間的排程使用 ex.每天中午12點執行一次排程
2.ScheduleAtFixedRate or ScheduleWithFixedDelay:
rate:等待rate時間就執行task
delay:該task執行完後,delay設定時間再繼續執行下一個task