Skip to content

Instantly share code, notes, and snippets.

@silmeth
Last active April 20, 2017 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save silmeth/9d5344fd2d7605bb0102770a728ecdb4 to your computer and use it in GitHub Desktop.
Save silmeth/9d5344fd2d7605bb0102770a728ecdb4 to your computer and use it in GitHub Desktop.
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