fix:线程阻塞问题处理

This commit is contained in:
2024-08-17 19:27:19 +08:00
parent c8e93afd42
commit cc507c307b
27 changed files with 226 additions and 172 deletions

View File

@@ -44,6 +44,7 @@
<type>pom</type> <type>pom</type>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.dromara.dynamictp</groupId> <groupId>org.dromara.dynamictp</groupId>
<artifactId>dynamic-tp-spring-boot-starter-adapter-webserver</artifactId> <artifactId>dynamic-tp-spring-boot-starter-adapter-webserver</artifactId>

View File

@@ -1,7 +1,6 @@
package org.nl.acs.agv; package org.nl.acs.agv;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpResponse;
@@ -42,7 +41,6 @@ public class QueryAGVStatus {
private DeviceAppService deviceAppService; private DeviceAppService deviceAppService;
public void run() { public void run() {
log.info("定时查询AGV状态"+ DateUtil.now());
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
TaskService taskService = SpringContextHolder.getBean(TaskService.class); TaskService taskService = SpringContextHolder.getBean(TaskService.class);
ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class); ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);

View File

@@ -301,7 +301,6 @@ public class NDCAgvServiceImpl implements NDCAgvService {
(byte) nextHighHigh, (byte) nextHighLow (byte) nextHighHigh, (byte) nextHighLow
}; };
log.info("反馈agv动作数据--index:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF) + ",phase:" + hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF)); log.info("反馈agv动作数据--index:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF) + ",phase:" + hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF));
System.out.println("反馈agv动作数据:" + Bytes2HexString(b)); System.out.println("反馈agv动作数据:" + Bytes2HexString(b));

View File

@@ -139,7 +139,7 @@ public class ItemProtocol {
setIsonline(true); setIsonline(true);
return value; return value;
} }
return value; return 0;
} }

View File

@@ -139,7 +139,7 @@ public class ItemProtocol {
setIsonline(true); setIsonline(true);
return value; return value;
} }
return value; return 0;
} }

View File

@@ -142,7 +142,7 @@ public class ItemProtocol {
setIsonline(true); setIsonline(true);
return value; return value;
} }
return value; return 0;
} }

View File

@@ -194,7 +194,7 @@ public class ItemProtocol {
setIsonline(true); setIsonline(true);
return value; return value;
} }
return value; return 0;
} }

View File

@@ -112,7 +112,7 @@ public class ItemProtocol {
setIsonline(true); setIsonline(true);
return value; return value;
} }
return value; return 0;
} }
public String getOpcStringValue(String protocol) { public String getOpcStringValue(String protocol) {

View File

@@ -178,7 +178,7 @@ public class ItemProtocol {
setIsonline(true); setIsonline(true);
return value; return value;
} }
return value; return 0;
} }
@@ -191,7 +191,7 @@ public class ItemProtocol {
setIsonline(true); setIsonline(true);
return value; return value;
} }
return value; return 0;
} }

View File

@@ -178,7 +178,7 @@ public class ItemProtocol {
setIsonline(true); setIsonline(true);
return value; return value;
} }
return value; return 0;
} }

View File

@@ -211,7 +211,7 @@ public class ItemProtocol {
setIsonline(true); setIsonline(true);
return value; return value;
} }
return value; return 0;
} }

View File

@@ -199,7 +199,7 @@ public class ItemProtocol {
setIsonline(true); setIsonline(true);
return value; return value;
} }
return value; return 0;
} }
public String getOpcStringValue(String protocol) { public String getOpcStringValue(String protocol) {

View File

@@ -184,7 +184,7 @@ public class ItemProtocol {
setIsonline(true); setIsonline(true);
return value; return value;
} }
return value; return 0;
} }
public static List<ItemDto> getReadableItemDtos() { public static List<ItemDto> getReadableItemDtos() {

View File

@@ -91,7 +91,7 @@ ItemProtocol {
} else { } else {
return value; return value;
} }
return "0"; return "";
} }
public static List<ItemDto> getReadableItemDtos() { public static List<ItemDto> getReadableItemDtos() {

View File

@@ -182,7 +182,7 @@ public class ItemProtocol {
setIsonline(true); setIsonline(true);
return value; return value;
} }
return value; return 0;
} }
public float getOpcFloatValue(String protocol) { public float getOpcFloatValue(String protocol) {

View File

@@ -177,7 +177,7 @@ public class ItemProtocol {
setIsonline(true); setIsonline(true);
return value; return value;
} }
return value; return 0;
} }
public float getOpcFloatValue(String protocol) { public float getOpcFloatValue(String protocol) {

View File

@@ -36,6 +36,7 @@ import org.nl.acs.monitor.DeviceStageMonitor;
import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.opc.DeviceAppServiceImpl; import org.nl.acs.opc.DeviceAppServiceImpl;
import org.nl.acs.route.service.RouteLineService; import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.enums.TaskTypeEnum;
import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto; import org.nl.acs.task.service.dto.TaskDto;
import org.nl.common.exception.BadRequestException; import org.nl.common.exception.BadRequestException;
@@ -49,6 +50,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import java.util.*; import java.util.*;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.stream.Collectors;
/** /**
* 烘箱-行架机械手 * 烘箱-行架机械手
@@ -331,19 +333,12 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
TaskDto task = null; TaskDto task = null;
for (int i = 0; i < getDeviceCodeList.size(); i++) { for (int i = 0; i < getDeviceCodeList.size(); i++) {
String startDeviceCode = getDeviceCodeList.get(i); String startDeviceCode = getDeviceCodeList.get(i);
//先查指令
List<TaskDto> taskDtos = taskserver.queryTaskByDeviceCodeAndStatus(startDeviceCode); List<TaskDto> taskDtos = taskserver.queryTaskByDeviceCodeAndStatus(startDeviceCode);
if (ObjectUtil.isNotEmpty(taskDtos)) { List<TaskDto> taskDtoStream = taskDtos.stream().sorted(Comparator.comparing(TaskDto::getCreate_time)).collect(Collectors.toList());
//按照优先级排序 优先级相等按照创建时间排序 if (ObjectUtil.isNotEmpty(taskDtoStream)) {
taskDtos = this.sortTask(taskDtos);
TaskDto taskDto = taskDtos.get(0); TaskDto taskDto = taskDtos.get(0);
if (TaskTypeEnum.Truss_Task.getIndex().equals(taskDto.getTask_type())) {
//存在行架->暂存的AGV任务 需要过滤
// 6 行架任务 8烘箱任务
if (!StrUtil.equals(taskDto.getTask_type(), "6") && !StrUtil.equals(taskDto.getTask_type(), "8")) {
taskDto = null;
continue;
}
Instruction instruction = instructionService.findByTaskcodeAndStatus(taskDto.getTask_code()); Instruction instruction = instructionService.findByTaskcodeAndStatus(taskDto.getTask_code());
String start_device_code = instruction.getStart_device_code(); String start_device_code = instruction.getStart_device_code();
String next_device_code = instruction.getNext_device_code(); String next_device_code = instruction.getNext_device_code();
@@ -465,25 +460,32 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
this.writing(list); this.writing(list);
this.setRequireSucess(true); this.setRequireSucess(true);
return true; return true;
}
} else { } else {
List<TaskDto> taskDtoList = taskserver.queryTaskByDeviceCode(startDeviceCode); List<TaskDto> taskDtoList = taskserver.findByTrappedManipulatorReady();
if (ObjectUtil.isNotEmpty(taskDtoList)) { if (ObjectUtil.isNotEmpty(taskDtoList)) {
for (int j = 0; j < taskDtoList.size(); j++) { List<TaskDto> taskDtosReady = new ArrayList<>();
for (TaskDto taskDto1 : taskDtoList) {
if (getDeviceCodeList.contains(taskDto1.getStart_device_code())) {
taskDtosReady.add(taskDto1);
}
}
// task = taskDtosReady.get(0);
List<TaskDto> readyTaskDtos = new ArrayList<>();
for (int j = 0; j < taskDtosReady.size(); j++) {
task = taskDtosReady.get(j);
readyTaskDtos.add(task);
}
//按照优先级排序 优先级相等按照创建时间排序 //按照优先级排序 优先级相等按照创建时间排序
taskDtoList = this.sortTask(taskDtoList); readyTaskDtos = this.sortTask(readyTaskDtos);
task = taskDtoList.get(j); task = readyTaskDtos.get(0);
// 6 行架任务 8烘箱任务
if (!StrUtil.equals(task.getTask_type(), "6") && !StrUtil.equals(task.getTask_type(), "8")) {
task = null;
continue;
} }
if (ObjectUtil.isNotEmpty(task)) { if (ObjectUtil.isNotEmpty(task)) {
break; break;
} }
} }
} }
}
}
if (!ObjectUtil.isEmpty(task)) { if (!ObjectUtil.isEmpty(task)) {
Device nextdevice = deviceAppService.findDeviceByCode(task.getNext_device_code()); Device nextdevice = deviceAppService.findDeviceByCode(task.getNext_device_code());
Device startdevice = deviceAppService.findDeviceByCode(task.getStart_device_code()); Device startdevice = deviceAppService.findDeviceByCode(task.getStart_device_code());
@@ -662,11 +664,11 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
list.add(map3); list.add(map3);
this.writing(list); this.writing(list);
this.setRequireSucess(true); this.setRequireSucess(true);
notCreateInstMessage = ""; return true;
notCreateTaskMessage = "";
} else { } else {
notCreateInstMessage = "未找到关联设备的任务,指令无法创建"; notCreateInstMessage = "未找到关联设备的任务,指令无法创建";
} }
return true; return true;
} }
} }

View File

@@ -183,7 +183,7 @@ public interface InstructionService extends CommonService<InstructionMybatis> {
* @param dto * @param dto
* @throws Exception * @throws Exception
*/ */
boolean create(Instruction dto) throws Exception; void create(Instruction dto) throws Exception;

View File

@@ -380,7 +380,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public boolean create(Instruction dto) throws Exception { public void create(Instruction dto) throws Exception {
dto = foramte(dto); dto = foramte(dto);
String task_code = dto.getTask_code(); String task_code = dto.getTask_code();
TaskDto task = taskService.findByCodeFromCache(task_code); TaskDto task = taskService.findByCodeFromCache(task_code);
@@ -394,7 +394,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
.eq(InstructionMybatis::getTask_code, dto.getTask_code())); .eq(InstructionMybatis::getTask_code, dto.getTask_code()));
if (CollUtil.isNotEmpty(instructionMybatis) && instructionMybatis.stream().anyMatch(inst -> inst.getStart_device_code() if (CollUtil.isNotEmpty(instructionMybatis) && instructionMybatis.stream().anyMatch(inst -> inst.getStart_device_code()
.equals(start_device_code))) { .equals(start_device_code))) {
return false; return;
} }
} }
String currentUsername = SecurityUtils.getCurrentNickName(); String currentUsername = SecurityUtils.getCurrentNickName();
@@ -538,7 +538,6 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
.build(); .build();
logDto1.setLog_level(4); logDto1.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto1); luceneExecuteLogService.deviceExecuteLog(logDto1);
return false;
} }
} else { } else {
// Boolean result = createLkInst(task.getStorage_task_type(),dto); // Boolean result = createLkInst(task.getStorage_task_type(),dto);
@@ -591,7 +590,6 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
InstructionMybatis entity = ConvertUtil.convert(dto, InstructionMybatis.class); InstructionMybatis entity = ConvertUtil.convert(dto, InstructionMybatis.class);
instructionMapper.insert(entity); instructionMapper.insert(entity);
instructions.add(dto); instructions.add(dto);
return true;
} }

View File

@@ -2,18 +2,22 @@ package org.nl.acs.opc;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.dromara.dynamictp.core.DtpRegistry; import org.dromara.dynamictp.core.DtpRegistry;
import org.dromara.dynamictp.core.executor.DtpExecutor;
import org.dromara.dynamictp.core.support.ExecutorWrapper;
import org.nl.acs.auto.run.AbstractAutoRunnable; import org.nl.acs.auto.run.AbstractAutoRunnable;
import org.nl.acs.auto.run.AutoRunService; import org.nl.acs.auto.run.AutoRunService;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.udw.UnifiedDataAccessor; import org.nl.acs.udw.UnifiedDataAccessor;
import org.nl.acs.udw.UnifiedDataAccessorFactory; import org.nl.acs.udw.UnifiedDataAccessorFactory;
import org.nl.config.SpringContextHolder;
import org.nl.config.thread.TheadFactoryName;
import org.nl.config.thread.ThreadPoolExecutorUtil; import org.nl.config.thread.ThreadPoolExecutorUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.lang.reflect.Field;
import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.concurrent.*; import java.util.concurrent.*;
@@ -34,7 +38,10 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable {
int loop_time_millions = 100; int loop_time_millions = 100;
@Resource
private ThreadPoolExecutor executorService;
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(30);
Map<String, BlockedRunable> runs; Map<String, BlockedRunable> runs;
@@ -114,8 +121,33 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable {
BlockedRunable runnable = new BlockedRunable() { BlockedRunable runnable = new BlockedRunable() {
@Override @Override
public void subRun() throws Exception { public void subRun() throws Exception {
// Thread.sleep(6000);
deviceDriver.executeAuto(); deviceDriver.executeAuto();
/* ThreadPoolExecutor executor= DtpRegistry.getDtpExecutor("dtpExecutor1");
Future<?> submit = executor.submit(() -> {
try {
deviceDriver.executeAuto();
} catch (Exception e) {
throw new RuntimeException(e);
}
});
try {
// 设置超时时间为 15 秒,如果任务超时,抛出 TimeoutException
submit.get(10, TimeUnit.SECONDS);
System.out.println();
} catch (TimeoutException e) {
System.out.println("任务超时,取消任务!");
// 使用反射获取 FutureTask 中的线程,并使用 Thread.stop() 强制终止
Field runnerField = submit.getClass().getDeclaredField("runner");
runnerField.setAccessible(true);
Thread runnerThread = (Thread) runnerField.get(submit);
if (runnerThread != null) {
runnerThread.stop(); // 强制终止线程(不推荐)
}
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}*/
} }
@Override @Override
@@ -127,16 +159,55 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable {
this.runs.put(deviceDriver.getDeviceCode(), runnable); this.runs.put(deviceDriver.getDeviceCode(), runnable);
} }
runnable.setIndex(this.runs); runnable.setIndex(this.runs);
// this.executorService.execute(runnable);
ExecutorService executorService = (ExecutorService) ThreadPoolExecutorUtil.getPoll(); Future<?> future = this.executorService.submit(runnable);
Future<?> future = executorService.submit(runnable); /* try {
// 设置超时时间为 30 秒,如果任务超时,抛出 TimeoutException
future.get(5, TimeUnit.SECONDS);
} catch (TimeoutException e) {
System.out.println("任务超时,取消任务!");
// 超时后取消任务,并设置为 true 以中断执行中的线程
future.cancel(true);
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}*/
ScheduledExecutorService scheduler= (ScheduledExecutorService) DtpRegistry.getExecutor("scheduled_pool"); //plc断连后强制终止线程
/* try {
// 设置超时时间为 15 秒,如果任务超时,抛出 TimeoutException
future.get(15, TimeUnit.SECONDS);
} catch (TimeoutException e) {
System.out.println("任务超时,取消任务!");
// 使用反射获取 FutureTask 中的线程,并使用 Thread.stop() 强制终止
Field runnerField = future.getClass().getDeclaredField("runner");
runnerField.setAccessible(true);
Thread runnerThread = (Thread) runnerField.get(future);
if (runnerThread != null) {
runnerThread.stop(); // 强制终止线程(不推荐)
}
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}*/
// 使用调度器在超时后取消任务 // 使用调度器在超时后取消任务
scheduler.schedule(() -> { scheduler.schedule(() -> {
if (!future.isDone()) { if (!future.isDone()) {
// future.cancel(true); // 尝试中断任务
// Field runnerField = null;
// try {
// runnerField = future.getClass().getDeclaredField("runner");
// runnerField.setAccessible(true);
// Thread runnerThread = (Thread) runnerField.get(future);
// if (runnerThread != null) {
// runnerThread.stop(); // 强制终止线程(不推荐)
// }
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
try { try {
// 设置超时时间为 30 秒,如果任务超时,抛出 TimeoutException // 设置超时时间为 30 秒,如果任务超时,抛出 TimeoutException
future.get(5, TimeUnit.SECONDS); future.get(5, TimeUnit.SECONDS);
@@ -147,8 +218,15 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable {
} catch (InterruptedException | ExecutionException e) { } catch (InterruptedException | ExecutionException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
}, 1, TimeUnit.MILLISECONDS); // 设置超时时间为10秒 }, 5, TimeUnit.SECONDS); // 设置超时时间为10秒
} }
} }
} }

View File

@@ -52,7 +52,6 @@ public class OpcUtl {
e1.printStackTrace(); e1.printStackTrace();
} }
boolean is_success = true; boolean is_success = true;
StringBuilder message = new StringBuilder(); StringBuilder message = new StringBuilder();
Iterator arg4 = e.keySet().iterator(); Iterator arg4 = e.keySet().iterator();

View File

@@ -48,6 +48,10 @@ public class Task extends CommonModel<Task> implements Serializable {
private String vehicle_code; private String vehicle_code;
private String vehicle_code2;
private String vehicle_type; private String vehicle_type;

View File

@@ -35,7 +35,7 @@ public class ThreadPoolExecutorUtil {
public static Executor getPoll(){ public static Executor getPoll(){
return DtpRegistry.getExecutor("cool_pool"); return DtpRegistry.getExecutor("dtpExecutor1");
/* AsyncTaskProperties properties = SpringContextHolder.getBean(AsyncTaskProperties.class); /* AsyncTaskProperties properties = SpringContextHolder.getBean(AsyncTaskProperties.class);
return new ThreadPoolExecutor( return new ThreadPoolExecutor(

View File

@@ -46,7 +46,6 @@ public class AutoCreateInst {
* 创建指令前需要判断是否条件具备:起始位置是否有货、目标位置是否有货 * 创建指令前需要判断是否条件具备:起始位置是否有货、目标位置是否有货
*/ */
public void run() throws Exception { public void run() throws Exception {
log.info("自动生成指令"+DateUtil.now());
TaskService taskserver = SpringContextHolder.getBean(TaskService.class); TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
@@ -194,9 +193,8 @@ public class AutoCreateInst {
} else { } else {
instdto.setAgv_inst_type("4"); instdto.setAgv_inst_type("4");
} }
boolean flag;
try { try {
flag = instructionService.create(instdto); instructionService.create(instdto);
} catch (Exception e) { } catch (Exception e) {
acsTask.setRemark(e.getMessage()); acsTask.setRemark(e.getMessage());
taskserver.updateByCodeFromCache(acsTask); taskserver.updateByCodeFromCache(acsTask);
@@ -209,11 +207,9 @@ public class AutoCreateInst {
continue; continue;
} }
//创建指令后修改任务状态 //创建指令后修改任务状态
if (flag) {
acsTask.setTask_status(TaskStatusEnum.BUSY.getIndex()); acsTask.setTask_status(TaskStatusEnum.BUSY.getIndex());
acsTask.setUpdate_time(DateUtil.now()); acsTask.setUpdate_time(DateUtil.now());
taskserver.update(acsTask); taskserver.update(acsTask);
}
} }
} }

View File

@@ -43,7 +43,6 @@ public class CreateDDJInst {
* 定时查询堆垛机任务 * 定时查询堆垛机任务
*/ */
public void run() { public void run() {
log.info("定时查询堆垛机任务"+DateUtil.now());
TaskService taskserver = SpringContextHolder.getBean(TaskService.class); TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);

View File

@@ -1,6 +1,5 @@
package org.nl.system.service.quartz.task; package org.nl.system.service.quartz.task;
import cn.hutool.core.date.DateUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.acs.auto.run.AutoRunService; import org.nl.acs.auto.run.AutoRunService;
import org.nl.system.service.param.ISysParamService; import org.nl.system.service.param.ISysParamService;
@@ -21,7 +20,6 @@ public class NdcAutoReconnection {
AutoRunService autoRunService; AutoRunService autoRunService;
public void run(String threadCode) throws Exception { public void run(String threadCode) throws Exception {
log.info("定时NDC自动重连"+ DateUtil.now());
String[] threadCodes = threadCode.split(","); String[] threadCodes = threadCode.split(",");
for (String code : threadCodes) { for (String code : threadCodes) {
if (!autoRunService.getThreadByCode(code).isAlive()) { if (!autoRunService.getThreadByCode(code).isAlive()) {

View File

@@ -51,40 +51,22 @@ spring:
monitorInterval: 8 monitorInterval: 8
tomcatTp: # tomcat webserver 线程池配置 tomcatTp: # tomcat webserver 线程池配置
threadPoolAliasName: tomcat 线程池 # 线程池别名,可选 threadPoolAliasName: tomcat 线程池 # 线程池别名,可选
corePoolSize: 30 corePoolSize: 10
maximumPoolSize: 50 maximumPoolSize: 50
keepAliveTime: 60 keepAliveTime: 60
runTimeout: 10000 runTimeout: 10000
queueTimeout: 100 queueTimeout: 100
executors: # 动态线程池配置,都有默认值,采用默认值的可以不配置该项,减少配置量 executors: # 动态线程池配置,都有默认值,采用默认值的可以不配置该项,减少配置量
- threadPoolName: cool_pool # 线程池名称,必填dtpExecutor1 - threadPoolName: dtpExecutor1 # 线程池名称,必填
threadPoolAliasName: core_thread # 线程池别名,可选 threadPoolAliasName: core_thread # 线程池别名,可选
executorType: common # 线程池类型 common、eager、ordered、scheduled、priority默认 common executorType: common # 线程池类型 common、eager、ordered、scheduled、priority默认 common
corePoolSize: 30 # 核心线程数默认1 corePoolSize: 10 # 核心线程数默认1
maximumPoolSize: 50 # 最大线程数默认cpu核数 maximumPoolSize: 30 # 最大线程数默认cpu核数
queueCapacity: 1024 # 队列容量默认1024 queueCapacity: 1024 # 队列容量默认1024
queueType: VariableLinkedBlockingQueue # 任务队列查看源码QueueTypeEnum枚举类默认VariableLinkedBlockingQueue queueType: VariableLinkedBlockingQueue # 任务队列查看源码QueueTypeEnum枚举类默认VariableLinkedBlockingQueue
rejectedHandlerType: CallerRunsPolicy # 拒绝策略查看RejectedTypeEnum枚举类默认AbortPolicy rejectedHandlerType: CallerRunsPolicy # 拒绝策略查看RejectedTypeEnum枚举类默认AbortPolicy
keepAliveTime: 30 # 空闲线程等待超时时间默认60 keepAliveTime: 30 # 空闲线程等待超时时间默认60
threadNamePrefix: core_thread # 线程名前缀默认dtp threadNamePrefix: core_thread # 线程名前缀默认dtp
tryInterrupt: true
allowCoreThreadTimeOut: true # 是否允许核心线程池超时默认false
waitForTasksToCompleteOnShutdown: true # 参考spring线程池设计优雅关闭线程池默认true
awaitTerminationSeconds: 5 # 优雅关闭线程池时阻塞等待线程池中任务执行时间默认3单位s
preStartAllCoreThreads: false # 是否预热所有核心线程默认false
runTimeout: 2000 # 任务执行超时阈值单位ms默认0不统计
queueTimeout: 1000 # 任务在队列等待超时阈值单位ms默认0不统计
- threadPoolName: scheduled_pool # 线程池名称,必填
threadPoolAliasName: scheduled_thread # 线程池别名,可选
executorType: scheduled # 线程池类型 common、eager、ordered、scheduled、priority默认 common
corePoolSize: 30 # 核心线程数默认1
maximumPoolSize: 50 # 最大线程数默认cpu核数
queueCapacity: 1024 # 队列容量默认1024
queueType: VariableLinkedBlockingQueue # 任务队列查看源码QueueTypeEnum枚举类默认VariableLinkedBlockingQueue
rejectedHandlerType: CallerRunsPolicy # 拒绝策略查看RejectedTypeEnum枚举类默认AbortPolicy
keepAliveTime: 30 # 空闲线程等待超时时间默认60
threadNamePrefix: scheduled_thread # 线程名前缀默认dtp
tryInterrupt: true
allowCoreThreadTimeOut: true # 是否允许核心线程池超时默认false allowCoreThreadTimeOut: true # 是否允许核心线程池超时默认false
waitForTasksToCompleteOnShutdown: true # 参考spring线程池设计优雅关闭线程池默认true waitForTasksToCompleteOnShutdown: true # 参考spring线程池设计优雅关闭线程池默认true
awaitTerminationSeconds: 5 # 优雅关闭线程池时阻塞等待线程池中任务执行时间默认3单位s awaitTerminationSeconds: 5 # 优雅关闭线程池时阻塞等待线程池中任务执行时间默认3单位s