mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-15 04:22:09 +08:00
enhancement #I37QVR WhenCondition时候,并发执行目前会每次新建线程可不可走线程池
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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...");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user