线程池统一管理
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
package com.ruoyi.quartz.mapper;
|
||||
|
||||
import com.ruoyi.quartz.domain.SysJobLog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.ruoyi.quartz.mapper;
|
||||
|
||||
import com.ruoyi.quartz.domain.SysJob;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -1,14 +1,13 @@
|
||||
package com.ruoyi.quartz.util;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import org.quartz.DisallowConcurrentExecution;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.scheduling.quartz.QuartzJobBean;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.constant.ScheduleConstants;
|
||||
@ -29,7 +28,7 @@ public class ScheduleJob extends QuartzJobBean
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(ScheduleJob.class);
|
||||
|
||||
private ExecutorService service = Executors.newSingleThreadExecutor();
|
||||
private ThreadPoolTaskExecutor executor = (ThreadPoolTaskExecutor) SpringContextUtil.getBean("publicThreadPool");
|
||||
|
||||
private final static ISysJobLogService jobLogService = (ISysJobLogService) SpringContextUtil.getBean("sysJobLogServiceImpl");
|
||||
|
||||
@ -53,7 +52,7 @@ public class ScheduleJob extends QuartzJobBean
|
||||
// 执行任务
|
||||
log.info("任务开始执行 - 名称:{} 方法:{}", job.getJobName(), job.getMethodName());
|
||||
ScheduleRunnable task = new ScheduleRunnable(job.getJobName(), job.getMethodName(), job.getMethodParams());
|
||||
Future<?> future = service.submit(task);
|
||||
Future<?> future = executor.submit(task);
|
||||
future.get();
|
||||
long times = System.currentTimeMillis() - startTime;
|
||||
// 任务状态 0:成功 1:失败
|
||||
|
Reference in New Issue
Block a user