Quartz 같은 job이 중복되게 작동하지 못하도록 하기

2024. 12. 24. 21:45배치

@DisallowConcurrentExecution annotation을 추가

import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

@DisallowConcurrentExecution
public class MyJob implements Job {
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        System.out.println("Executing job: " + context.getJobDetail().getKey());
        // Simulate a long-running task
        try {
            Thread.sleep(5000); // 5 seconds
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

'배치' 카테고리의 다른 글

Crontab에서 job 중복 실행 방지  (0) 2024.12.24