enhancement #I37QVR WhenCondition时候,并发执行目前会每次新建线程可不可走线程池

This commit is contained in:
徐佳
2021-03-26 21:38:13 +08:00
parent e41db2e7b8
commit 617440db25
13 changed files with 148 additions and 54 deletions

View File

@@ -2,6 +2,7 @@ package com.yomahub.liteflow.springboot;
import com.yomahub.liteflow.property.LiteflowConfig;
import com.yomahub.liteflow.util.ExecutorHelper;
import com.yomahub.liteflow.util.Shutdown;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Bean;
@@ -19,7 +20,7 @@ import java.util.concurrent.ExecutorService;
@AutoConfigureAfter({LiteflowPropertyAutoConfiguration.class})
public class LiteflowExecutorAutoConfiguration {
@Bean
@Bean("whenExecutors")
public ExecutorService executorService(LiteflowConfig liteflowConfig) {
int useWorker = liteflowConfig.getWhenMaxWorkers();
int useQueue = liteflowConfig.getWhenQueueLimit();
@@ -33,4 +34,9 @@ public class LiteflowExecutorAutoConfiguration {
return ExecutorHelper.buildExecutor(useWorker, useQueue, "liteflow-when-calls", false);
}
@Bean
public Shutdown shutdown() {
return new Shutdown();
}
}

View File

@@ -1,34 +0,0 @@
package com.yomahub.liteflow.springboot;
import com.yomahub.liteflow.util.ExecutorHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;
import java.util.concurrent.ExecutorService;
/**
* 关闭shutdown类
* 执行清理工作
* @author justin.xu
*/
@Order(Integer.MIN_VALUE)
@Component
public class Shutdown {
private static final Logger LOG = LoggerFactory.getLogger(Shutdown.class);
@Resource
private ExecutorService executorService;
@PreDestroy
public void destroy() throws Exception {
LOG.info("Start closing the liteflow-when-calls...");
ExecutorHelper.shutdownAwaitTermination(executorService);
LOG.info("Succeed closing the liteflow-when-calls ok...");
}
}