Scheduled Tasks

ScheduledTask

To define a instance with a task that will be executed periodically.

Parameters

ParametersDescription
loglogger will be used for inform (slf4j logger instance)
threadNameName of the thread
threadIntervalInterval of the thread in milliseconds
errorTryCountThresholdThreshold to try on error condition
errorSleepTimeTime to sleep on error in milliseconds

Example

The following example logs "Hello World" to the consle for each 2 seconds

@Component
@Slf4j
public class MyScheduledTask extends ScheduledTask {
public MyScheduledTask() {
super(log
, "MyThread"
, 2 * 1000
, 0
, 1000 * 15);
}
@Override
protected void doThreadJob() throws Exception {
log.info("Hello World!!");
}
}