now there is a scheduled task in the project, which is executed in the early hours of every day, but one day the amount of data is so large that the task has not been finished for one day, and has been executed until the next day, and then the task begins to be executed again. So it causes data duplication
related codes
/***
* sqlserver
* @throws Exception
*/
@Scheduled(cron = "0 0 1 * * ?")
public void switchDate(){}
it says so, now I want to see if the same task is finished at the same time when the task is executed, and postpone the task execution time if it is not finished. I checked that the concurrent
attribute of Quartz is similar to that of
. It goes like this:
where theconcurrent
attribute identification is interpreted as: for the sameJobDetail
, when you specify multipleTrigger
, it is likely that the second job starts before the first job is completed. Specifyconcurrent
tofalse
, multiple job will not run concurrently, and the second job will not start before the first job is completed.so is the second job at this point delayed or cancelled? Today, I did a small experiment with this question as follows: set the
Trigger
of the task to be executed every 10 seconds, and then letThread
pause 15 seconds inside the executing task, so that there must be time overlap between different job . After starting the program, it is found that the number of seconds at the end of the previous job execution is 15 , and the second job , which was originally executed in 10s , starts immediately.thus, the
concurrent
attribute actually delays the execution of job.