Last active
April 20, 2017 14:47
-
-
Save silmeth/9d5344fd2d7605bb0102770a728ecdb4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.time.Instant; | |
import com.github.kagkarlsson.scheduler.Scheduler; | |
import com.github.kagkarlsson.scheduler.task.DeadExecutionHandler; | |
import com.github.kagkarlsson.scheduler.task.OnStartup; | |
import com.github.kagkarlsson.scheduler.task.Schedule; | |
import com.github.kagkarlsson.scheduler.task.Task; | |
public abstract class FixedRateTask extends Task implements OnStartup { | |
public static final String INSTANCE = "fixedRate"; | |
public FixedRateTask(String name, Schedule schedule) { | |
super(name, new OnCompleteRescheduleByPreviousExecution(schedule), | |
new DeadExecutionHandler.RescheduleDeadExecution()); | |
} | |
@Override | |
public void onStartup(Scheduler scheduler) { | |
scheduler.scheduleForExecution(Instant.now(), this.instance(INSTANCE)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment