With the advances in Lambda and ECS task scheduling, I have not needed to use the trusty Quartz library for the past few years. I recently had to use it though in a project, and realized that the next job was starting when the current job was still running.
Thankfully with Spring, Quartz 2 makes this really easy. Just add the @DisallowConcurrentExecution
to your job.
package com.lab49.example;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.job;
import org.quartz.job.JobExecutionContext;
@DisallowConcurrentExecution
public class TestJob implements Job {
@Override
public void execute(JobExecutionContext context) {
// job logic here
}
}