后置处理逻辑
This commit is contained in:
parent
d5bb9b1404
commit
3cb633c938
@ -46,4 +46,16 @@ public class ExecutorConfig {
|
||||
executor.initialize(); // 必须手动触发初始化
|
||||
return executor;
|
||||
}
|
||||
@Bean("postHandlerExecutor")
|
||||
public ThreadPoolTaskExecutor postHandlerExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor.setCorePoolSize(10);
|
||||
executor.setMaxPoolSize(10);
|
||||
executor.setQueueCapacity(100);
|
||||
executor.setThreadNamePrefix("postHandler-");
|
||||
ThreadPoolExecutor.CallerRunsPolicy callerRunsPolicy = new ThreadPoolExecutor.CallerRunsPolicy();
|
||||
executor.setRejectedExecutionHandler(callerRunsPolicy);
|
||||
executor.initialize(); // 必须手动触发初始化
|
||||
return executor;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,9 @@ import cd.casic.ci.process.engine.postHandler.ExecuteTaskPostHandler;
|
||||
import cd.casic.ci.process.process.dataObject.history.PipPipelineHisInstance;
|
||||
import cd.casic.framework.commons.exception.ServiceException;
|
||||
import cd.casic.framework.commons.exception.enums.GlobalErrorCodeConstants;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@ -16,6 +18,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
@Component
|
||||
public class MemoryPostHandlerManager implements PostHandlerManager {
|
||||
private final ConcurrentHashMap<String, List<ExecuteTaskPostHandler>> handlerMap = new ConcurrentHashMap<>();
|
||||
@Resource
|
||||
private ThreadPoolTaskExecutor postHandlerExecutor;
|
||||
@Override
|
||||
public void registerPostHandler(ExecuteTaskPostHandler handler) {
|
||||
if (handler==null|| StringUtils.isEmpty(handler.getPipelineId())) {
|
||||
@ -34,7 +38,7 @@ public class MemoryPostHandlerManager implements PostHandlerManager {
|
||||
return;
|
||||
}
|
||||
for (ExecuteTaskPostHandler postHandler : pipExecutePostHandlers) {
|
||||
postHandler.executeAfterDone(hisInstance);
|
||||
postHandlerExecutor.submit(()->postHandler.executeAfterDone(hisInstance));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user