前言
使用唯品会的saturn来管理定时任务
一、使用步骤
继承AbstractSaturnJavaJob并重写handleJavaJob方法
代码如下(示例):
@Component
@Slf4j
public class xxxJob extends AbstractSaturnJavaJob {
public void execute() {
xxx;
}
@Override
public SaturnJobReturn handleJavaJob(String s, Integer integer, String s1, SaturnJobExecutionContext saturnJobExecutionContext) throws InterruptedException {
try {
execute();
} catch (Exception e) {
log.error("xxx", e);
throw e;
}
SaturnJobReturn jr = new SaturnJobReturn();
jr.setReturnCode(SaturnSystemReturnCode.SUCCESS);
jr.setErrorGroup(SaturnSystemErrorGroup.SUCCESS);
return jr;
}
}