xxl-job任务超时和手动停止任务无效原因解决方法
实例:
不生效的原因:
/**
* 1、简单任务示例(Bean模式)
*/
@XxlJob("demoJobHandler")
public ReturnT<String> demoJobHandler(String param) throws Exception {
XxlJobLogger.log("XXL-JOB, Hello World.");
for (int i = 0; i < 5; i++) {
try {
XxlJobLogger.log("beat at:" + i);
System.out.println("第"+i+"次");
TimeUnit.SECONDS.sleep(3);
}catch (Exception e){
e.printStackTrace();
}
}
return ReturnT.SUCCESS;
}
实例:正确写法
/**
* 1、简单任务示例(Bean模式)
*/
@XxlJob("demoJobHandler")
public ReturnT<String> demoJobHandler(String param) throws Exception {
XxlJobLogger.log("XXL-JOB, Hello World.");
for (int i = 0; i < 5; i++) {
try {
XxlJobLogger.log("beat at:" + i);
System.out.println("第"+i+"次");
TimeUnit.SECONDS.sleep(3);
}catch (Exception e){
if (e instanceof InterruptedException){
throw e;
}
}
}
return ReturnT.SUCCESS;
}
当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »