Bladeren bron

feature #IAPI07 chain维度线程池隔离

jason 7 maanden geleden
bovenliggende
commit
f34b3e9cc5
100 gewijzigde bestanden met toevoegingen van 2330 en 305 verwijderingen
  1. 9 2
      liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/LiteFlowChainELBuilder.java
  2. 23 7
      liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/ThreadPoolOperator.java
  3. 1 1
      liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/WhenOperator.java
  4. 2 0
      liteflow-core/src/main/java/com/yomahub/liteflow/common/ChainConstant.java
  5. 13 4
      liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/Chain.java
  6. 2 1
      liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/ForCondition.java
  7. 2 1
      liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/IteratorCondition.java
  8. 10 0
      liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/LoopCondition.java
  9. 1 1
      liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/WhileCondition.java
  10. 22 7
      liteflow-core/src/main/java/com/yomahub/liteflow/flow/parallel/strategy/ParallelStrategyExecutor.java
  11. 1 1
      liteflow-core/src/main/java/com/yomahub/liteflow/flow/parallel/strategy/SpecifyParallelExecutor.java
  12. 13 15
      liteflow-core/src/main/java/com/yomahub/liteflow/parser/helper/ParserHelper.java
  13. 46 90
      liteflow-core/src/main/java/com/yomahub/liteflow/property/LiteflowConfig.java
  14. 35 7
      liteflow-core/src/main/java/com/yomahub/liteflow/thread/ExecutorHelper.java
  15. 6 6
      liteflow-core/src/main/java/com/yomahub/liteflow/thread/LiteFlowDefaultGlobalExecutorBuilder.java
  16. 1 0
      liteflow-core/src/main/resources/dtd/liteflow.dtd
  17. 4 6
      liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/config/LiteflowAutoConfiguration.java
  18. 62 0
      liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/config/LiteflowProperty.java
  19. 3 3
      liteflow-solon-plugin/src/main/resources/META-INF/liteflow-default.properties
  20. 47 65
      liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/LiteflowProperty.java
  21. 3 6
      liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/config/LiteflowPropertyAutoConfiguration.java
  22. 13 34
      liteflow-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json
  23. 3 6
      liteflow-spring-boot-starter/src/main/resources/META-INF/liteflow-default.properties
  24. 2 2
      liteflow-testcase-el/liteflow-testcase-el-builder/src/test/java/com/yomahub/liteflow/test/builder/customTreadExecutor/CustomThreadExecutor1.java
  25. 72 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/java/com/yomahub/liteflow/test/chainThreadPool/ChainThreadPoolELSpringbootTest.java
  26. 73 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/java/com/yomahub/liteflow/test/chainThreadPool/ConditionThreadPoolELSpringbootTest.java
  27. 23 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomChainThreadExecutor.java
  28. 23 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomGlobalThreadExecutor.java
  29. 23 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomLoopThreadExecutor.java
  30. 23 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomWhenThreadExecutor.java
  31. 71 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/java/com/yomahub/liteflow/test/chainThreadPool/GlobalThreadPoolELSpringbootTest.java
  32. 81 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/CmpConfig.java
  33. 2 2
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomThreadExecutor1.java
  34. 2 2
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomThreadExecutor2.java
  35. 2 2
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomThreadExecutor3.java
  36. 1 1
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolELDeclMultiSpringbootTest.java
  37. 2 2
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/java/com/yomahub/liteflow/test/parallelLoop/CustomThreadExecutor.java
  38. 1 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/resources/chainThreadPool/application.properties
  39. 2 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/resources/chainThreadPool/application2.properties
  40. 4 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/resources/chainThreadPool/application3.properties
  41. 22 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/resources/chainThreadPool/flow.el.xml
  42. 22 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/resources/chainThreadPool/flow2.el.xml
  43. 19 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/resources/chainThreadPool/flow3.el.xml
  44. 3 3
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/resources/parallelLoop/application.properties
  45. 79 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/ChainThreadPoolELSpringbootTest.java
  46. 79 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/ConditionThreadPoolELSpringbootTest.java
  47. 23 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomChainThreadExecutor.java
  48. 23 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomGlobalThreadExecutor.java
  49. 23 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomLoopThreadExecutor.java
  50. 23 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomWhenThreadExecutor.java
  51. 79 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/GlobalThreadPoolELSpringbootTest.java
  52. 81 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/CmpConfig.java
  53. 2 2
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomThreadExecutor1.java
  54. 2 2
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomThreadExecutor2.java
  55. 2 2
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomThreadExecutor3.java
  56. 2 3
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolELDeclMultiSpringbootTest.java
  57. 2 2
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/parallelLoop/CustomThreadExecutor.java
  58. 1 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/chainThreadPool/application.properties
  59. 2 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/chainThreadPool/application2.properties
  60. 4 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/chainThreadPool/application3.properties
  61. 22 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/chainThreadPool/flow.el.xml
  62. 22 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/chainThreadPool/flow2.el.xml
  63. 19 0
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/chainThreadPool/flow3.el.xml
  64. 3 3
      liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/parallelLoop/application.properties
  65. 79 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/ChainThreadPoolELSpringbootTest.java
  66. 79 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/ConditionThreadPoolELSpringbootTest.java
  67. 23 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomChainThreadExecutor.java
  68. 23 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomGlobalThreadExecutor.java
  69. 23 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomLoopThreadExecutor.java
  70. 23 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomWhenThreadExecutor.java
  71. 79 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/GlobalThreadPoolELSpringbootTest.java
  72. 24 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/ACmp.java
  73. 27 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/BCmp.java
  74. 81 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/CmpConfig.java
  75. 32 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/DCmp.java
  76. 19 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/FCmp.java
  77. 27 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/ICmp.java
  78. 23 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/ITCmp.java
  79. 27 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/WCmp.java
  80. 25 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/ZCmp.java
  81. 2 2
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomThreadExecutor1.java
  82. 2 2
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomThreadExecutor2.java
  83. 2 2
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomThreadExecutor3.java
  84. 2 3
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolELDeclSpringbootTest.java
  85. 2 2
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/parallelLoop/CustomThreadExecutor.java
  86. 1 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/chainThreadPool/application.properties
  87. 2 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/chainThreadPool/application2.properties
  88. 4 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/chainThreadPool/application3.properties
  89. 22 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/chainThreadPool/flow.el.xml
  90. 22 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/chainThreadPool/flow2.el.xml
  91. 19 0
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/chainThreadPool/flow3.el.xml
  92. 3 3
      liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/parallelLoop/application.properties
  93. 76 0
      liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/chainThreadPool/ChainThreadPoolELSpringbootTest.java
  94. 76 0
      liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/chainThreadPool/ConditionThreadPoolELSpringbootTest.java
  95. 23 0
      liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomChainThreadExecutor.java
  96. 23 0
      liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomGlobalThreadExecutor.java
  97. 23 0
      liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomLoopThreadExecutor.java
  98. 23 0
      liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomWhenThreadExecutor.java
  99. 80 0
      liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/chainThreadPool/GlobalThreadPoolELSpringbootTest.java
  100. 21 0
      liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/ACmp.java

+ 9 - 2
liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/LiteFlowChainELBuilder.java

@@ -1,7 +1,10 @@
 package com.yomahub.liteflow.builder.el;
 package com.yomahub.liteflow.builder.el;
 
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.util.*;
+import cn.hutool.core.util.ArrayUtil;
+import cn.hutool.core.util.CharUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
 import com.fasterxml.jackson.databind.JsonMappingException;
 import com.fasterxml.jackson.databind.JsonMappingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.ql.util.express.DefaultContext;
 import com.ql.util.express.DefaultContext;
@@ -30,7 +33,6 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.List;
 import java.util.List;
 import java.util.Objects;
 import java.util.Objects;
-import java.util.function.Consumer;
 
 
 /**
 /**
  * Chain基于代码形式的组装器 EL表达式规则专属组装器
  * Chain基于代码形式的组装器 EL表达式规则专属组装器
@@ -243,6 +245,11 @@ public class LiteFlowChainELBuilder {
 		return this;
 		return this;
 	}
 	}
 
 
+    public LiteFlowChainELBuilder setThreadPoolExecutorClass(String threadPoolExecutorClass) {
+        this.chain.setThreadPoolExecutorClass(threadPoolExecutorClass);
+        return this;
+    }
+
     /**
     /**
      * EL表达式校验,此方法已经过时,请使用 {@link LiteFlowChainELBuilder#validateWithEx(String)}
      * EL表达式校验,此方法已经过时,请使用 {@link LiteFlowChainELBuilder#validateWithEx(String)}
      *
      *

+ 23 - 7
liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/ThreadPoolOperator.java

@@ -1,27 +1,43 @@
 package com.yomahub.liteflow.builder.el.operator;
 package com.yomahub.liteflow.builder.el.operator;
 
 
+import com.ql.util.express.exception.QLException;
 import com.yomahub.liteflow.builder.el.operator.base.BaseOperator;
 import com.yomahub.liteflow.builder.el.operator.base.BaseOperator;
 import com.yomahub.liteflow.builder.el.operator.base.OperatorHelper;
 import com.yomahub.liteflow.builder.el.operator.base.OperatorHelper;
+import com.yomahub.liteflow.flow.element.Condition;
+import com.yomahub.liteflow.flow.element.condition.LoopCondition;
 import com.yomahub.liteflow.flow.element.condition.WhenCondition;
 import com.yomahub.liteflow.flow.element.condition.WhenCondition;
 
 
 /**
 /**
- * EL规则中的threadPool的操作符
+ * EL规则中的threadPool的操作符 有四种用法  WHEN().threadPool() FOR...DO().threadPool() WHILE...DO.threadPool() ITERATOR...DO
+ * .threadPool()
  *
  *
  * @author Bryan.Zhang
  * @author Bryan.Zhang
  * @since 2.8.0
  * @since 2.8.0
  */
  */
-public class ThreadPoolOperator extends BaseOperator<WhenCondition> {
+public class ThreadPoolOperator extends BaseOperator<Condition> {
 
 
 	@Override
 	@Override
-	public WhenCondition build(Object[] objects) throws Exception {
+	public Condition build(Object[] objects) throws Exception {
 		OperatorHelper.checkObjectSizeEqTwo(objects);
 		OperatorHelper.checkObjectSizeEqTwo(objects);
 
 
-		String errorMsg = "The caller must be WhenCondition item";
-		WhenCondition whenCondition = OperatorHelper.convert(objects[0], WhenCondition.class, errorMsg);
+		if (objects[0] instanceof WhenCondition) {
+			String errorMsg = "The caller must be WhenCondition item";
 
 
-		whenCondition.setThreadExecutorClass(OperatorHelper.convert(objects[1], String.class));
+			WhenCondition condition = OperatorHelper.convert(objects[0], WhenCondition.class, errorMsg);
 
 
-		return whenCondition;
+			condition.setThreadExecutorClass(OperatorHelper.convert(objects[1], String.class));
+			return condition;
+		} else if (objects[0] instanceof LoopCondition) {
+			String errorMsg = "The caller must be LoopCondition item";
+
+			LoopCondition condition = OperatorHelper.convert(objects[0], LoopCondition.class, errorMsg);
+
+			condition.setThreadPoolExecutorClass(OperatorHelper.convert(objects[1], String.class));
+			return condition;
+		} else {
+            String errorMsg = "The caller must be WhenCondition or LoopCondition item";
+			throw new QLException(errorMsg);
+		}
 	}
 	}
 
 
 }
 }

+ 1 - 1
liteflow-core/src/main/java/com/yomahub/liteflow/builder/el/operator/WhenOperator.java

@@ -25,7 +25,7 @@ public class WhenOperator extends BaseOperator<WhenCondition> {
 		for (Object obj : objects) {
 		for (Object obj : objects) {
 			OperatorHelper.checkObjMustBeCommonTypeItem(obj);
 			OperatorHelper.checkObjMustBeCommonTypeItem(obj);
 			whenCondition.addExecutable(OperatorHelper.convert(obj, Executable.class));
 			whenCondition.addExecutable(OperatorHelper.convert(obj, Executable.class));
-			whenCondition.setThreadExecutorClass(liteflowConfig.getThreadExecutorClass());
+			whenCondition.setThreadExecutorClass(liteflowConfig.getGlobalThreadPoolExecutorClass());
 		}
 		}
 		return whenCondition;
 		return whenCondition;
 	}
 	}

+ 2 - 0
liteflow-core/src/main/java/com/yomahub/liteflow/common/ChainConstant.java

@@ -34,6 +34,8 @@ public interface ChainConstant {
 
 
 	String NAMESPACE = "namespace";
 	String NAMESPACE = "namespace";
 
 
+    String THREAD_POOL_EXECUTOR_CLASS = "thread-pool-executor-class";
+
 	String DEFAULT_NAMESPACE = "default";
 	String DEFAULT_NAMESPACE = "default";
 
 
 	String VALUE = "value";
 	String VALUE = "value";

+ 13 - 4
liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/Chain.java

@@ -12,18 +12,17 @@ import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.BooleanUtil;
 import cn.hutool.core.util.BooleanUtil;
 import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder;
 import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder;
 import com.yomahub.liteflow.common.ChainConstant;
 import com.yomahub.liteflow.common.ChainConstant;
+import com.yomahub.liteflow.enums.ExecuteableTypeEnum;
 import com.yomahub.liteflow.exception.ChainEndException;
 import com.yomahub.liteflow.exception.ChainEndException;
+import com.yomahub.liteflow.exception.FlowSystemException;
 import com.yomahub.liteflow.lifecycle.LifeCycleHolder;
 import com.yomahub.liteflow.lifecycle.LifeCycleHolder;
-import com.yomahub.liteflow.lifecycle.PostProcessChainExecuteLifeCycle;
 import com.yomahub.liteflow.log.LFLog;
 import com.yomahub.liteflow.log.LFLog;
 import com.yomahub.liteflow.log.LFLoggerManager;
 import com.yomahub.liteflow.log.LFLoggerManager;
 import com.yomahub.liteflow.slot.DataBus;
 import com.yomahub.liteflow.slot.DataBus;
 import com.yomahub.liteflow.slot.Slot;
 import com.yomahub.liteflow.slot.Slot;
-import com.yomahub.liteflow.enums.ExecuteableTypeEnum;
-import com.yomahub.liteflow.exception.FlowSystemException;
+
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
-import java.util.function.Consumer;
 
 
 /**
 /**
  * chain对象,实现可执行器
  * chain对象,实现可执行器
@@ -46,6 +45,8 @@ public class Chain implements Executable{
 
 
 	private String namespace = ChainConstant.DEFAULT_NAMESPACE;
 	private String namespace = ChainConstant.DEFAULT_NAMESPACE;
 
 
+    private String threadPoolExecutorClass;
+
 	public Chain(String chainName) {
 	public Chain(String chainName) {
 		this.chainId = chainName;
 		this.chainId = chainName;
 	}
 	}
@@ -223,4 +224,12 @@ public class Chain implements Executable{
 	public void setNamespace(String namespace) {
 	public void setNamespace(String namespace) {
 		this.namespace = namespace;
 		this.namespace = namespace;
 	}
 	}
+
+    public String getThreadPoolExecutorClass() {
+        return threadPoolExecutorClass;
+    }
+
+    public void setThreadPoolExecutorClass(String threadPoolExecutorClass) {
+        this.threadPoolExecutorClass = threadPoolExecutorClass;
+    }
 }
 }

+ 2 - 1
liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/ForCondition.java

@@ -77,7 +77,8 @@ public class ForCondition extends LoopCondition {
                 //存储所有的并行执行子项的CompletableFuture
                 //存储所有的并行执行子项的CompletableFuture
                 List<CompletableFuture<LoopFutureObj>> futureList = new ArrayList<>();
                 List<CompletableFuture<LoopFutureObj>> futureList = new ArrayList<>();
                 //获取并行循环的线程池
                 //获取并行循环的线程池
-                ExecutorService parallelExecutor = ExecutorHelper.loadInstance().buildLoopParallelExecutor();
+                ExecutorService parallelExecutor = ExecutorHelper.loadInstance().buildLoopParallelExecutor(this,
+                                                                                                           slotIndex);
                 for (int i = 0; i < forCount; i++){
                 for (int i = 0; i < forCount; i++){
                     //提交异步任务
                     //提交异步任务
                     CompletableFuture<LoopFutureObj> future =
                     CompletableFuture<LoopFutureObj> future =

+ 2 - 1
liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/IteratorCondition.java

@@ -80,7 +80,8 @@ public class IteratorCondition extends LoopCondition {
                 //存储所有的并行执行子项的CompletableFuture
                 //存储所有的并行执行子项的CompletableFuture
                 List<CompletableFuture<LoopFutureObj>> futureList = new ArrayList<>();
                 List<CompletableFuture<LoopFutureObj>> futureList = new ArrayList<>();
                 //获取并行循环的线程池
                 //获取并行循环的线程池
-                ExecutorService parallelExecutor = ExecutorHelper.loadInstance().buildLoopParallelExecutor();
+                ExecutorService parallelExecutor = ExecutorHelper.loadInstance().buildLoopParallelExecutor(this,
+                                                                                                           slotIndex);
                 while (it.hasNext()) {
                 while (it.hasNext()) {
                     Object itObj = it.next();
                     Object itObj = it.next();
                     //提交异步任务
                     //提交异步任务

+ 10 - 0
liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/LoopCondition.java

@@ -20,6 +20,8 @@ import java.util.function.Supplier;
 public abstract class LoopCondition extends Condition {
 public abstract class LoopCondition extends Condition {
     //判断循环是否并行执行,默认为false
     //判断循环是否并行执行,默认为false
     private boolean parallel = false;
     private boolean parallel = false;
+    //loop condition层级的线程池
+    private String threadPoolExecutorClass;
 
 
     protected Executable getBreakItem() {
     protected Executable getBreakItem() {
         return this.getExecutableOne(ConditionKey.BREAK_KEY);
         return this.getExecutableOne(ConditionKey.BREAK_KEY);
@@ -37,6 +39,14 @@ public abstract class LoopCondition extends Condition {
         this.addExecutable(ConditionKey.DO_KEY, executable);
         this.addExecutable(ConditionKey.DO_KEY, executable);
     }
     }
 
 
+    public String getThreadPoolExecutorClass() {
+        return threadPoolExecutorClass;
+    }
+
+    public void setThreadPoolExecutorClass(String threadPoolExecutorClass) {
+        this.threadPoolExecutorClass = threadPoolExecutorClass;
+    }
+
     protected void setLoopIndex(Executable executableItem, int index) {
     protected void setLoopIndex(Executable executableItem, int index) {
         if (executableItem instanceof Chain) {
         if (executableItem instanceof Chain) {
             ((Chain) executableItem).getConditionList().forEach(condition -> setLoopIndex(condition, index));
             ((Chain) executableItem).getConditionList().forEach(condition -> setLoopIndex(condition, index));

+ 1 - 1
liteflow-core/src/main/java/com/yomahub/liteflow/flow/element/condition/WhileCondition.java

@@ -61,7 +61,7 @@ public class WhileCondition extends LoopCondition {
 			//并行循环逻辑
 			//并行循环逻辑
 			List<CompletableFuture<LoopFutureObj>> futureList = new ArrayList<>();
 			List<CompletableFuture<LoopFutureObj>> futureList = new ArrayList<>();
 			//获取并行循环的线程池
 			//获取并行循环的线程池
-			ExecutorService parallelExecutor = ExecutorHelper.loadInstance().buildLoopParallelExecutor();
+            ExecutorService parallelExecutor = ExecutorHelper.loadInstance().buildLoopParallelExecutor(this, slotIndex);
 			while (getWhileResult(slotIndex, index)){
 			while (getWhileResult(slotIndex, index)){
 				CompletableFuture<LoopFutureObj> future =
 				CompletableFuture<LoopFutureObj> future =
 						CompletableFuture.supplyAsync(new LoopParallelSupplier(executableItem, this.getCurrChainId(), slotIndex, index), parallelExecutor);
 						CompletableFuture.supplyAsync(new LoopParallelSupplier(executableItem, this.getCurrChainId(), slotIndex, index), parallelExecutor);

+ 22 - 7
liteflow-core/src/main/java/com/yomahub/liteflow/flow/parallel/strategy/ParallelStrategyExecutor.java

@@ -5,6 +5,8 @@ import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.StrUtil;
 import com.yomahub.liteflow.enums.ParallelStrategyEnum;
 import com.yomahub.liteflow.enums.ParallelStrategyEnum;
 import com.yomahub.liteflow.exception.WhenExecuteException;
 import com.yomahub.liteflow.exception.WhenExecuteException;
+import com.yomahub.liteflow.flow.FlowBus;
+import com.yomahub.liteflow.flow.element.Chain;
 import com.yomahub.liteflow.flow.element.Executable;
 import com.yomahub.liteflow.flow.element.Executable;
 import com.yomahub.liteflow.flow.element.Node;
 import com.yomahub.liteflow.flow.element.Node;
 import com.yomahub.liteflow.flow.element.condition.FinallyCondition;
 import com.yomahub.liteflow.flow.element.condition.FinallyCondition;
@@ -122,18 +124,31 @@ public abstract class ParallelStrategyExecutor {
      * @param whenCondition
      * @param whenCondition
      * @return
      * @return
      */
      */
-    protected ExecutorService getWhenExecutorService(WhenCondition whenCondition) {
+    protected ExecutorService getWhenExecutorService(WhenCondition whenCondition, Integer slotIndex) {
 
 
         LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
         LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
-
-        // 如果设置了线程池隔离,则每个 when 都会有对应的线程池,这是为了避免多层嵌套时如果线程池数量不够时出现单个线程池死锁。用线程池隔离的方式会更加好
-        // 如果 when 没有超多层的嵌套,还是用默认的比较好。
-        // 默认设置不隔离。也就是说,默认情况是一个线程池类一个实例,如果什么都不配置,那也就是在 when 的情况下,全局一个线程池。
+        //线程池的优先级 condition层级>chain层级>全局体系
+        // 1、如果设置了线程池隔离,则每个 when 都会有对应的线程池,这是为了避免多层嵌套时如果线程池数量不够时出现单个线程池死锁。用线程池隔离的方式会更加好
+        // 2、如果在chain上自定义线程池,同一个chain下的when+异步线程池共享一个线程池
+        // 3、默认全局一个线程池,所有的when+异步共享一个线程池
         ExecutorService parallelExecutor;
         ExecutorService parallelExecutor;
 
 
+        String chainId = DataBus.getSlot(slotIndex).getChainId();
+
+        Chain chain = FlowBus.getChain(chainId);
+
         if (BooleanUtil.isTrue(liteflowConfig.getWhenThreadPoolIsolate())) {
         if (BooleanUtil.isTrue(liteflowConfig.getWhenThreadPoolIsolate())) {
-            parallelExecutor = ExecutorHelper.loadInstance().buildWhenExecutorWithHash(whenCondition.getThreadExecutorClass(), String.valueOf(whenCondition.hashCode()));
+            //condition层级线程池
+            parallelExecutor =
+                    ExecutorHelper.loadInstance().buildWhenExecutorWithHash(whenCondition.getThreadExecutorClass(),
+                                                                            String.valueOf(whenCondition.hashCode()));
+        } else if (ObjectUtil.isNotEmpty(chain.getThreadPoolExecutorClass())) {
+            //chain层级线程池
+            parallelExecutor =
+                    ExecutorHelper.loadInstance().buildWhenExecutorWithHash(chain.getThreadPoolExecutorClass(),
+                                                                            String.valueOf(chain.hashCode()));
         } else {
         } else {
+            //全局线程池
             parallelExecutor = ExecutorHelper.loadInstance().buildWhenExecutor(whenCondition.getThreadExecutorClass());
             parallelExecutor = ExecutorHelper.loadInstance().buildWhenExecutor(whenCondition.getThreadExecutorClass());
         }
         }
 
 
@@ -155,7 +170,7 @@ public abstract class ParallelStrategyExecutor {
         this.setWhenConditionParams(whenCondition);
         this.setWhenConditionParams(whenCondition);
 
 
         // 获取 WHEN 所需线程池
         // 获取 WHEN 所需线程池
-        ExecutorService parallelExecutor = getWhenExecutorService(whenCondition);
+        ExecutorService parallelExecutor = getWhenExecutorService(whenCondition, slotIndex);
 
 
         // 这里主要是做了封装 CompletableFuture 对象,用 lambda 表达式做了很多事情,这句代码要仔细理清
         // 这里主要是做了封装 CompletableFuture 对象,用 lambda 表达式做了很多事情,这句代码要仔细理清
         // 根据 condition.getNodeList() 的集合进行流处理,用 map 进行把 executable 对象转换成 List<CompletableFuture<WhenFutureObj>>
         // 根据 condition.getNodeList() 的集合进行流处理,用 map 进行把 executable 对象转换成 List<CompletableFuture<WhenFutureObj>>

+ 1 - 1
liteflow-core/src/main/java/com/yomahub/liteflow/flow/parallel/strategy/SpecifyParallelExecutor.java

@@ -26,7 +26,7 @@ public class SpecifyParallelExecutor extends ParallelStrategyExecutor {
         this.setWhenConditionParams(whenCondition);
         this.setWhenConditionParams(whenCondition);
 
 
         // 获取 WHEN 所需线程池
         // 获取 WHEN 所需线程池
-        ExecutorService parallelExecutor = getWhenExecutorService(whenCondition);
+        ExecutorService parallelExecutor = getWhenExecutorService(whenCondition, slotIndex);
 
 
         // 指定完成的任务
         // 指定完成的任务
         CompletableFuture<?> specifyTask;
         CompletableFuture<?> specifyTask;

+ 13 - 15
liteflow-core/src/main/java/com/yomahub/liteflow/parser/helper/ParserHelper.java

@@ -1,6 +1,5 @@
 package com.yomahub.liteflow.parser.helper;
 package com.yomahub.liteflow.parser.helper;
 
 
-import cn.hutool.core.util.BooleanUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.StrUtil;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.JsonNode;
@@ -17,15 +16,8 @@ import com.yomahub.liteflow.util.ElRegexUtil;
 import org.dom4j.Document;
 import org.dom4j.Document;
 import org.dom4j.Element;
 import org.dom4j.Element;
 
 
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.Set;
+import java.util.*;
 import java.util.function.Consumer;
 import java.util.function.Consumer;
-import java.util.function.Function;
 
 
 import static com.yomahub.liteflow.common.ChainConstant.*;
 import static com.yomahub.liteflow.common.ChainConstant.*;
 
 
@@ -96,10 +88,6 @@ public class ParserHelper {
                 .build();
                 .build();
     }
     }
 
 
-    /**
-     * xml 形式的主要解析过程
-     * @param documentList documentList
-     */
     /**
     /**
      * xml 形式的主要解析过程
      * xml 形式的主要解析过程
      * @param documentList documentList
      * @param documentList documentList
@@ -316,7 +304,12 @@ public class ParserHelper {
 
 
         JsonNode routeJsonNode = chainNode.get(ROUTE);
         JsonNode routeJsonNode = chainNode.get(ROUTE);
 
 
-        LiteFlowChainELBuilder builder = LiteFlowChainELBuilder.createChain().setChainId(chainId).setNamespace(namespace);
+        String threadPoolExecutorClass = chainNode.get(THREAD_POOL_EXECUTOR_CLASS) == null ? null :
+                chainNode.get(THREAD_POOL_EXECUTOR_CLASS).textValue();
+
+        LiteFlowChainELBuilder builder =
+                LiteFlowChainELBuilder.createChain().setChainId(chainId).setNamespace(namespace)
+                .setThreadPoolExecutorClass(threadPoolExecutorClass);
 
 
         // 如果有route这个标签,说明是决策表chain
         // 如果有route这个标签,说明是决策表chain
         // 决策表链路必须有route和body这两个标签
         // 决策表链路必须有route和body这两个标签
@@ -347,7 +340,12 @@ public class ParserHelper {
 
 
         Element routeElement = e.element(ROUTE);
         Element routeElement = e.element(ROUTE);
 
 
-        LiteFlowChainELBuilder builder = LiteFlowChainELBuilder.createChain().setChainId(chainId).setNamespace(namespace);
+        String threadPoolExecutorClass = e.attributeValue(THREAD_POOL_EXECUTOR_CLASS) == null ? null :
+                e.attributeValue(THREAD_POOL_EXECUTOR_CLASS);
+
+        LiteFlowChainELBuilder builder =
+                LiteFlowChainELBuilder.createChain().setChainId(chainId).setNamespace(namespace)
+                .setThreadPoolExecutorClass(threadPoolExecutorClass);
 
 
         // 如果有route这个标签,说明是决策表chain
         // 如果有route这个标签,说明是决策表chain
         // 决策表链路必须有route和body这两个标签
         // 决策表链路必须有route和body这两个标签

+ 46 - 90
liteflow-core/src/main/java/com/yomahub/liteflow/property/LiteflowConfig.java

@@ -13,7 +13,6 @@ import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.StrUtil;
 import com.yomahub.liteflow.enums.ParseModeEnum;
 import com.yomahub.liteflow.enums.ParseModeEnum;
 
 
-import java.util.HashMap;
 import java.util.Map;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeUnit;
 
 
@@ -42,9 +41,6 @@ public class LiteflowConfig {
 	// slot的数量
 	// slot的数量
 	private Integer slotSize;
 	private Integer slotSize;
 
 
-	// 并行线程执行器class路径
-	private String threadExecutorClass;
-
 	// 异步线程最大等待秒数
 	// 异步线程最大等待秒数
 	@Deprecated
 	@Deprecated
 	private Integer whenMaxWaitSeconds;
 	private Integer whenMaxWaitSeconds;
@@ -68,10 +64,8 @@ public class LiteflowConfig {
 	// 每隔多少秒打印
 	// 每隔多少秒打印
 	private Long period;
 	private Long period;
 
 
-	// 异步线程池最大线程数
-	private Integer whenMaxWorkers;
-
 	// 异步线程池最大队列数量
 	// 异步线程池最大队列数量
+	@Deprecated
 	private Integer whenQueueLimit;
 	private Integer whenQueueLimit;
 
 
 	// 解析模式,一共有三种,具体看其定义
 	// 解析模式,一共有三种,具体看其定义
@@ -105,15 +99,6 @@ public class LiteflowConfig {
 
 
 	// 规则文件/脚本文件变更监听
 	// 规则文件/脚本文件变更监听
 	private Boolean enableMonitorFile = Boolean.FALSE;
 	private Boolean enableMonitorFile = Boolean.FALSE;
-
-	//并行循环线程池所用class路径
-	private String parallelLoopExecutorClass;
-
-	//使用默认并行循环线程池时,最大线程数
-	private Integer parallelMaxWorkers;
-
-	//使用默认并行循环线程池时,最大队列数
-	private Integer parallelQueueLimit;
 	
 	
 	// 是否启用组件降级
 	// 是否启用组件降级
 	private Boolean fallbackCmpEnable;
 	private Boolean fallbackCmpEnable;
@@ -132,6 +117,15 @@ public class LiteflowConfig {
 		this.enableMonitorFile = enableMonitorFile;
 		this.enableMonitorFile = enableMonitorFile;
 	}
 	}
 
 
+	//全局线程池所用class路径(when+异步循环)
+	private String globalThreadPoolExecutorClass;
+
+	//全局线程池最大线程数(when+异步循环)
+	private Integer globalThreadPoolSize;
+
+	//全局线程池最大队列数(when+异步循环)
+	private Integer globalThreadPoolQueueSize;
+
 	public Boolean getEnable() {
 	public Boolean getEnable() {
 		if (ObjectUtil.isNull(enable)) {
 		if (ObjectUtil.isNull(enable)) {
 			return Boolean.TRUE;
 			return Boolean.TRUE;
@@ -231,32 +225,6 @@ public class LiteflowConfig {
 		this.enableLog = enableLog;
 		this.enableLog = enableLog;
 	}
 	}
 
 
-	public Integer getWhenMaxWorkers() {
-		if (ObjectUtil.isNull(whenMaxWorkers)) {
-			return 16;
-		}
-		else {
-			return whenMaxWorkers;
-		}
-	}
-
-	public void setWhenMaxWorkers(Integer whenMaxWorkers) {
-		this.whenMaxWorkers = whenMaxWorkers;
-	}
-
-	public Integer getWhenQueueLimit() {
-		if (ObjectUtil.isNull(whenQueueLimit)) {
-			return 512;
-		}
-		else {
-			return whenQueueLimit;
-		}
-	}
-
-	public void setWhenQueueLimit(Integer whenQueueLimit) {
-		this.whenQueueLimit = whenQueueLimit;
-	}
-
 	public Boolean isSupportMultipleType() {
 	public Boolean isSupportMultipleType() {
 		if (ObjectUtil.isNull(supportMultipleType)) {
 		if (ObjectUtil.isNull(supportMultipleType)) {
 			return Boolean.FALSE;
 			return Boolean.FALSE;
@@ -298,18 +266,6 @@ public class LiteflowConfig {
 		this.printBanner = printBanner;
 		this.printBanner = printBanner;
 	}
 	}
 
 
-	public String getThreadExecutorClass() {
-		if (StrUtil.isBlank(threadExecutorClass)) {
-			return "com.yomahub.liteflow.thread.LiteFlowDefaultWhenExecutorBuilder";
-		}
-		else {
-			return threadExecutorClass;
-		}
-	}
-
-	public void setThreadExecutorClass(String threadExecutorClass) {
-		this.threadExecutorClass = threadExecutorClass;
-	}
 
 
 	public String getNodeExecutorClass() {
 	public String getNodeExecutorClass() {
 		if (StrUtil.isBlank(nodeExecutorClass)) {
 		if (StrUtil.isBlank(nodeExecutorClass)) {
@@ -411,42 +367,6 @@ public class LiteflowConfig {
 	public void setWhenMaxWaitTimeUnit(TimeUnit whenMaxWaitTimeUnit) {
 	public void setWhenMaxWaitTimeUnit(TimeUnit whenMaxWaitTimeUnit) {
 		this.whenMaxWaitTimeUnit = whenMaxWaitTimeUnit;
 		this.whenMaxWaitTimeUnit = whenMaxWaitTimeUnit;
 	}
 	}
-
-	public Integer getParallelMaxWorkers() {
-		if(ObjectUtil.isNull(parallelMaxWorkers)){
-			return 16;
-		}else{
-			return parallelMaxWorkers;
-		}
-	}
-
-	public void setParallelMaxWorkers(Integer parallelMaxWorkers) {
-		this.parallelMaxWorkers = parallelMaxWorkers;
-	}
-
-	public Integer getParallelQueueLimit() {
-		if(ObjectUtil.isNull(parallelQueueLimit)){
-			return 512;
-		}else{
-			return parallelQueueLimit;
-		}
-	}
-
-	public void setParallelQueueLimit(Integer parallelQueueLimit) {
-		this.parallelQueueLimit = parallelQueueLimit;
-	}
-
-	public String getParallelLoopExecutorClass() {
-		if (StrUtil.isBlank(parallelLoopExecutorClass)) {
-			return "com.yomahub.liteflow.thread.LiteFlowDefaultParallelLoopExecutorBuilder";
-		}
-		else {
-			return parallelLoopExecutorClass;
-		}
-	}
-	public void setParallelLoopExecutorClass(String parallelLoopExecutorClass) {
-		this.parallelLoopExecutorClass = parallelLoopExecutorClass;
-	}
 	
 	
 	public Boolean getFallbackCmpEnable() {
 	public Boolean getFallbackCmpEnable() {
 		if (ObjectUtil.isNull(this.fallbackCmpEnable)) {
 		if (ObjectUtil.isNull(this.fallbackCmpEnable)) {
@@ -509,4 +429,40 @@ public class LiteflowConfig {
 	public void setScriptSetting(Map<String, String> scriptSetting) {
 	public void setScriptSetting(Map<String, String> scriptSetting) {
 		this.scriptSetting = scriptSetting;
 		this.scriptSetting = scriptSetting;
 	}
 	}
+
+	public Integer getGlobalThreadPoolSize() {
+		if (ObjectUtil.isNull(globalThreadPoolSize)) {
+			return 16;
+		} else {
+			return globalThreadPoolSize;
+		}
+	}
+
+	public void setGlobalThreadPoolSize(Integer globalThreadPoolSize) {
+		this.globalThreadPoolSize = globalThreadPoolSize;
+	}
+
+	public Integer getGlobalThreadPoolQueueSize() {
+		if (ObjectUtil.isNull(globalThreadPoolQueueSize)) {
+			return 512;
+		} else {
+			return globalThreadPoolQueueSize;
+		}
+	}
+
+	public void setGlobalThreadPoolQueueSize(Integer globalThreadPoolQueueSize) {
+		this.globalThreadPoolQueueSize = globalThreadPoolQueueSize;
+	}
+
+	public String getGlobalThreadPoolExecutorClass() {
+		if (StrUtil.isBlank(globalThreadPoolExecutorClass)) {
+			return "com.yomahub.liteflow.thread.LiteFlowDefaultGlobalExecutorBuilder";
+		} else {
+			return globalThreadPoolExecutorClass;
+		}
+	}
+
+	public void setGlobalThreadPoolExecutorClass(String globalThreadPoolExecutorClass) {
+		this.globalThreadPoolExecutorClass = globalThreadPoolExecutorClass;
+	}
 }
 }

+ 35 - 7
liteflow-core/src/main/java/com/yomahub/liteflow/thread/ExecutorHelper.java

@@ -12,16 +12,19 @@ import cn.hutool.core.map.MapUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.StrUtil;
 import com.yomahub.liteflow.exception.ThreadExecutorServiceCreateException;
 import com.yomahub.liteflow.exception.ThreadExecutorServiceCreateException;
+import com.yomahub.liteflow.flow.FlowBus;
+import com.yomahub.liteflow.flow.element.Chain;
+import com.yomahub.liteflow.flow.element.condition.LoopCondition;
 import com.yomahub.liteflow.log.LFLog;
 import com.yomahub.liteflow.log.LFLog;
 import com.yomahub.liteflow.log.LFLoggerManager;
 import com.yomahub.liteflow.log.LFLoggerManager;
 import com.yomahub.liteflow.property.LiteflowConfig;
 import com.yomahub.liteflow.property.LiteflowConfig;
 import com.yomahub.liteflow.property.LiteflowConfigGetter;
 import com.yomahub.liteflow.property.LiteflowConfigGetter;
+import com.yomahub.liteflow.slot.DataBus;
 import com.yomahub.liteflow.spi.holder.ContextAwareHolder;
 import com.yomahub.liteflow.spi.holder.ContextAwareHolder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 import java.util.Map;
 import java.util.Map;
-import java.util.concurrent.*;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
 
 
 /**
 /**
  * 线程池工具类
  * 线程池工具类
@@ -89,7 +92,7 @@ public class ExecutorHelper {
 	// 构建默认when线程池
 	// 构建默认when线程池
 	public ExecutorService buildWhenExecutor() {
 	public ExecutorService buildWhenExecutor() {
 		LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
 		LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
-		return buildWhenExecutor(liteflowConfig.getThreadExecutorClass());
+		return buildWhenExecutor(liteflowConfig.getGlobalThreadPoolExecutorClass());
 	}
 	}
 
 
 	// 构建when线程池 - 支持多个when公用一个线程池
 	// 构建when线程池 - 支持多个when公用一个线程池
@@ -103,7 +106,7 @@ public class ExecutorHelper {
 	// 构建when线程池 - clazz和condition的hash值共同作为缓存key
 	// 构建when线程池 - clazz和condition的hash值共同作为缓存key
 	public ExecutorService buildWhenExecutorWithHash(String conditionHash) {
 	public ExecutorService buildWhenExecutorWithHash(String conditionHash) {
 		LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
 		LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
-		return buildWhenExecutorWithHash(liteflowConfig.getThreadExecutorClass(), conditionHash);
+		return buildWhenExecutorWithHash(liteflowConfig.getGlobalThreadPoolExecutorClass(), conditionHash);
 	}
 	}
 
 
 	// 构建when线程池 - clazz和condition的hash值共同作为缓存key
 	// 构建when线程池 - clazz和condition的hash值共同作为缓存key
@@ -128,9 +131,34 @@ public class ExecutorHelper {
 	}
 	}
 
 
 	//构造并行循环的线程池
 	//构造并行循环的线程池
-	public ExecutorService buildLoopParallelExecutor(){
+	public ExecutorService buildLoopParallelExecutor(LoopCondition loopCondition, Integer slotIndex) {
+		ExecutorService parallelExecutor;
 		LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
 		LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
-		return getExecutorService(liteflowConfig.getParallelLoopExecutorClass());
+		String chainId = DataBus.getSlot(slotIndex).getChainId();
+		Chain chain = FlowBus.getChain(chainId);
+
+		//线程池的优先级 condition层级>chain层级>全局体系
+		// 1、如果设置了线程池隔离,则每个 异步 都会有对应的线程池,这是为了避免多层嵌套时如果线程池数量不够时出现单个线程池死锁。用线程池隔离的方式会更加好
+		// 2、如果在chain上自定义线程池,同一个chain下的when+异步线程池共享一个线程池
+		// 3、默认全局一个线程池,所有的when+异步共享一个线程池
+
+		if (ObjectUtil.isNotEmpty(loopCondition.getThreadPoolExecutorClass())) {
+			//condition层级线程池
+			parallelExecutor = getExecutorService(loopCondition.getThreadPoolExecutorClass(),
+												  String.valueOf(loopCondition.hashCode()));
+
+		} else if (ObjectUtil.isNotEmpty(chain.getThreadPoolExecutorClass())) {
+			//chain层级线程池
+			parallelExecutor = getExecutorService(chain.getThreadPoolExecutorClass(),
+												  String.valueOf(chain.hashCode()));
+
+		} else {
+			//全局线程池
+			parallelExecutor = getExecutorService(liteflowConfig.getGlobalThreadPoolExecutorClass());
+
+		}
+
+		return parallelExecutor;
 	}
 	}
 
 
 	private ExecutorService getExecutorService(String clazz){
 	private ExecutorService getExecutorService(String clazz){

+ 6 - 6
liteflow-core/src/main/java/com/yomahub/liteflow/thread/LiteFlowDefaultParallelLoopExecutorBuilder.java → liteflow-core/src/main/java/com/yomahub/liteflow/thread/LiteFlowDefaultGlobalExecutorBuilder.java

@@ -7,13 +7,12 @@ import com.yomahub.liteflow.property.LiteflowConfigGetter;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.ExecutorService;
 
 
 /**
 /**
- * LiteFlow默认的并行循环执行器实现
+ * LiteFlow默认全局线程池执行器实现
  *
  *
- * @author zhhhhy
- * @since 2.11.0
+ * @author jason
  */
  */
+public class LiteFlowDefaultGlobalExecutorBuilder implements ExecutorBuilder {
 
 
-public class LiteFlowDefaultParallelLoopExecutorBuilder implements ExecutorBuilder {
     @Override
     @Override
     public ExecutorService buildExecutor() {
     public ExecutorService buildExecutor() {
         LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
         LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
@@ -21,7 +20,8 @@ public class LiteFlowDefaultParallelLoopExecutorBuilder implements ExecutorBuild
         if (ObjectUtil.isNull(liteflowConfig)) {
         if (ObjectUtil.isNull(liteflowConfig)) {
             liteflowConfig = new LiteflowConfig();
             liteflowConfig = new LiteflowConfig();
         }
         }
-        return buildDefaultExecutor(liteflowConfig.getParallelMaxWorkers(), liteflowConfig.getParallelMaxWorkers(),
-                liteflowConfig.getParallelQueueLimit(), "loop-thread-");
+        return buildDefaultExecutor(liteflowConfig.getGlobalThreadPoolSize(), liteflowConfig.getGlobalThreadPoolSize(),
+                                    liteflowConfig.getGlobalThreadPoolQueueSize(), "global-thread-");
     }
     }
+
 }
 }

+ 1 - 0
liteflow-core/src/main/resources/dtd/liteflow.dtd

@@ -22,4 +22,5 @@
         extends CDATA #IMPLIED
         extends CDATA #IMPLIED
         enable (true|false) #IMPLIED
         enable (true|false) #IMPLIED
         namespace CDATA #IMPLIED
         namespace CDATA #IMPLIED
+        thread-pool-executor-class CDATA #IMPLIED
         >
         >

+ 4 - 6
liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/config/LiteflowAutoConfiguration.java

@@ -29,14 +29,11 @@ public class LiteflowAutoConfiguration {
 		liteflowConfig.setRuleSourceExtData(property.getRuleSourceExtData());
 		liteflowConfig.setRuleSourceExtData(property.getRuleSourceExtData());
 		liteflowConfig.setRuleSourceExtDataMap(property.getRuleSourceExtDataMap());
 		liteflowConfig.setRuleSourceExtDataMap(property.getRuleSourceExtDataMap());
 		liteflowConfig.setSlotSize(property.getSlotSize());
 		liteflowConfig.setSlotSize(property.getSlotSize());
-		liteflowConfig.setThreadExecutorClass(property.getThreadExecutorClass());
 		liteflowConfig.setWhenMaxWaitSeconds(property.getWhenMaxWaitSeconds());
 		liteflowConfig.setWhenMaxWaitSeconds(property.getWhenMaxWaitSeconds());
 		liteflowConfig.setEnableLog(liteflowMonitorProperty.isEnableLog());
 		liteflowConfig.setEnableLog(liteflowMonitorProperty.isEnableLog());
 		liteflowConfig.setQueueLimit(liteflowMonitorProperty.getQueueLimit());
 		liteflowConfig.setQueueLimit(liteflowMonitorProperty.getQueueLimit());
 		liteflowConfig.setDelay(liteflowMonitorProperty.getDelay());
 		liteflowConfig.setDelay(liteflowMonitorProperty.getDelay());
 		liteflowConfig.setPeriod(liteflowMonitorProperty.getPeriod());
 		liteflowConfig.setPeriod(liteflowMonitorProperty.getPeriod());
-		liteflowConfig.setWhenMaxWorkers(property.getWhenMaxWorkers());
-		liteflowConfig.setWhenQueueLimit(property.getWhenQueueLimit());
 		liteflowConfig.setParseMode(property.getParseMode());
 		liteflowConfig.setParseMode(property.getParseMode());
 		liteflowConfig.setEnable(property.isEnable());
 		liteflowConfig.setEnable(property.isEnable());
 		liteflowConfig.setSupportMultipleType(property.isSupportMultipleType());
 		liteflowConfig.setSupportMultipleType(property.isSupportMultipleType());
@@ -47,10 +44,11 @@ public class LiteflowAutoConfiguration {
 		liteflowConfig.setMainExecutorWorks(property.getMainExecutorWorks());
 		liteflowConfig.setMainExecutorWorks(property.getMainExecutorWorks());
 		liteflowConfig.setMainExecutorClass(property.getMainExecutorClass());
 		liteflowConfig.setMainExecutorClass(property.getMainExecutorClass());
 		liteflowConfig.setPrintExecutionLog(property.isPrintExecutionLog());
 		liteflowConfig.setPrintExecutionLog(property.isPrintExecutionLog());
-		liteflowConfig.setParallelMaxWorkers(property.getParallelMaxWorkers());
-		liteflowConfig.setParallelQueueLimit(property.getParallelQueueLimit());
-		liteflowConfig.setParallelLoopExecutorClass(property.getParallelLoopExecutorClass());
 		liteflowConfig.setFallbackCmpEnable(property.isFallbackCmpEnable());
 		liteflowConfig.setFallbackCmpEnable(property.isFallbackCmpEnable());
+        liteflowConfig.setGlobalThreadPoolExecutorClass(property.getGlobalThreadPoolExecutorClass());
+        liteflowConfig.setGlobalThreadPoolSize(property.getGlobalThreadPoolSize());
+        liteflowConfig.setGlobalThreadPoolQueueSize(property.getGlobalThreadPoolQueueSize());
+        liteflowConfig.setWhenThreadPoolIsolate(property.getWhenThreadPoolIsolate());
 		return liteflowConfig;
 		return liteflowConfig;
 	}
 	}
 
 

+ 62 - 0
liteflow-solon-plugin/src/main/java/com/yomahub/liteflow/solon/config/LiteflowProperty.java

@@ -1,5 +1,7 @@
 package com.yomahub.liteflow.solon.config;
 package com.yomahub.liteflow.solon.config;
 
 
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
 import com.yomahub.liteflow.enums.ParseModeEnum;
 import com.yomahub.liteflow.enums.ParseModeEnum;
 import org.noear.solon.annotation.Configuration;
 import org.noear.solon.annotation.Configuration;
 import org.noear.solon.annotation.Inject;
 import org.noear.solon.annotation.Inject;
@@ -83,6 +85,18 @@ public class LiteflowProperty {
 	// 是否启用组件降级
 	// 是否启用组件降级
 	private Boolean fallbackCmpEnable;
 	private Boolean fallbackCmpEnable;
 
 
+    //全局线程池所用class路径
+    private String globalThreadPoolExecutorClass;
+
+    //全局线程池最大线程数
+    private Integer globalThreadPoolSize;
+
+    //全局线程池最大队列数
+    private Integer globalThreadPoolQueueSize;
+
+    // 异步线程池是否隔离
+    private Boolean whenThreadPoolIsolate;
+
 	public boolean isEnable() {
 	public boolean isEnable() {
 		return enable;
 		return enable;
 	}
 	}
@@ -267,4 +281,52 @@ public class LiteflowProperty {
 	public Boolean getFallbackCmpEnable() {
 	public Boolean getFallbackCmpEnable() {
 		return fallbackCmpEnable;
 		return fallbackCmpEnable;
 	}
 	}
+
+    public Integer getGlobalThreadPoolSize() {
+        if (ObjectUtil.isNull(globalThreadPoolSize)) {
+            return 16;
+        } else {
+            return globalThreadPoolSize;
+        }
+    }
+
+    public void setGlobalThreadPoolSize(Integer globalThreadPoolSize) {
+        this.globalThreadPoolSize = globalThreadPoolSize;
+    }
+
+    public Integer getGlobalThreadPoolQueueSize() {
+        if (ObjectUtil.isNull(globalThreadPoolQueueSize)) {
+            return 512;
+        } else {
+            return globalThreadPoolQueueSize;
+        }
+    }
+
+    public void setGlobalThreadPoolQueueSize(Integer globalThreadPoolQueueSize) {
+        this.globalThreadPoolQueueSize = globalThreadPoolQueueSize;
+    }
+
+    public String getGlobalThreadPoolExecutorClass() {
+        if (StrUtil.isBlank(globalThreadPoolExecutorClass)) {
+            return "com.yomahub.liteflow.thread.LiteFlowDefaultGlobalExecutorBuilder";
+        } else {
+            return globalThreadPoolExecutorClass;
+        }
+    }
+
+    public void setGlobalThreadPoolExecutorClass(String globalThreadPoolExecutorClass) {
+        this.globalThreadPoolExecutorClass = globalThreadPoolExecutorClass;
+    }
+
+    public Boolean getWhenThreadPoolIsolate() {
+        if (ObjectUtil.isNull(whenThreadPoolIsolate)) {
+            return Boolean.FALSE;
+        } else {
+            return whenThreadPoolIsolate;
+        }
+    }
+
+    public void setWhenThreadPoolIsolate(Boolean whenThreadPoolIsolate) {
+        this.whenThreadPoolIsolate = whenThreadPoolIsolate;
+    }
 }
 }

+ 3 - 3
liteflow-solon-plugin/src/main/resources/META-INF/liteflow-default.properties

@@ -4,10 +4,7 @@ liteflow.slot-size=1024
 liteflow.main-executor-works=64
 liteflow.main-executor-works=64
 liteflow.main-executor-class=com.yomahub.liteflow.thread.LiteFlowDefaultMainExecutorBuilder
 liteflow.main-executor-class=com.yomahub.liteflow.thread.LiteFlowDefaultMainExecutorBuilder
 liteflow.request-id-generator-class=com.yomahub.liteflow.flow.id.DefaultRequestIdGenerator
 liteflow.request-id-generator-class=com.yomahub.liteflow.flow.id.DefaultRequestIdGenerator
-liteflow.thread-executor-class=com.yomahub.liteflow.thread.LiteFlowDefaultWhenExecutorBuilder
 liteflow.when-max-wait-seconds=15
 liteflow.when-max-wait-seconds=15
-liteflow.when-max-workers=16
-liteflow.when-queue-limit=512
 liteflow.parse-on-start=true
 liteflow.parse-on-start=true
 liteflow.retry-count=0
 liteflow.retry-count=0
 liteflow.support-multiple-type=false
 liteflow.support-multiple-type=false
@@ -18,3 +15,6 @@ liteflow.monitor.queue-limit=200
 liteflow.monitor.delay=300000
 liteflow.monitor.delay=300000
 liteflow.monitor.period=300000
 liteflow.monitor.period=300000
 liteflow.fallback-cmp-enable=false
 liteflow.fallback-cmp-enable=false
+liteflow.global-thread-pool-size=16
+liteflow.global-thread-pool-queue-size=512
+liteflow.global-thread-pool-executor-class=com.yomahub.liteflow.thread.LiteFlowDefaultGlobalExecutorBuilder

+ 47 - 65
liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/LiteflowProperty.java

@@ -1,5 +1,7 @@
 package com.yomahub.liteflow.springboot;
 package com.yomahub.liteflow.springboot;
 
 
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
 import com.yomahub.liteflow.enums.ParseModeEnum;
 import com.yomahub.liteflow.enums.ParseModeEnum;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 
 
@@ -35,9 +37,6 @@ public class LiteflowProperty {
 	// FlowExecutor的execute2Future的自定义线程池
 	// FlowExecutor的execute2Future的自定义线程池
 	private String mainExecutorClass;
 	private String mainExecutorClass;
 
 
-	// 并行线程执行器class路径
-	private String threadExecutorClass;
-
 	// 异步线程最大等待描述
 	// 异步线程最大等待描述
 	@Deprecated
 	@Deprecated
 	private int whenMaxWaitSeconds;
 	private int whenMaxWaitSeconds;
@@ -46,12 +45,6 @@ public class LiteflowProperty {
 
 
 	private TimeUnit whenMaxWaitTimeUnit;
 	private TimeUnit whenMaxWaitTimeUnit;
 
 
-	// 异步线程池最大线程数
-	private int whenMaxWorkers;
-
-	// 异步线程池最大队列数量
-	private int whenQueueLimit;
-
 	// 异步线程池是否隔离
 	// 异步线程池是否隔离
 	private boolean whenThreadPoolIsolate;
 	private boolean whenThreadPoolIsolate;
 
 
@@ -80,14 +73,6 @@ public class LiteflowProperty {
 
 
 	// 规则文件/脚本文件变更监听
 	// 规则文件/脚本文件变更监听
 	private boolean enableMonitorFile;
 	private boolean enableMonitorFile;
-
-	private String parallelLoopExecutorClass;
-
-	//使用默认并行循环线程池时,最大线程数
-	private int parallelMaxWorkers;
-
-	//使用默认并行循环线程池时,最大队列数
-	private int parallelQueueLimit;
 	
 	
 	// 是否启用组件降级
 	// 是否启用组件降级
 	private boolean fallbackCmpEnable;
 	private boolean fallbackCmpEnable;
@@ -101,6 +86,15 @@ public class LiteflowProperty {
 	//脚本特殊设置选项
 	//脚本特殊设置选项
 	private Map<String, String> scriptSetting;
 	private Map<String, String> scriptSetting;
 
 
+    //全局线程池所用class路径(when+异步循环)
+    private String globalThreadPoolExecutorClass;
+
+    //全局线程池最大线程数(when+异步循环)
+    private Integer globalThreadPoolSize;
+
+    //全局线程池最大队列数(when+异步循环)
+    private Integer globalThreadPoolQueueSize;
+
 	public boolean isEnableMonitorFile() {
 	public boolean isEnableMonitorFile() {
 		return enableMonitorFile;
 		return enableMonitorFile;
 	}
 	}
@@ -143,22 +137,6 @@ public class LiteflowProperty {
 		this.whenMaxWaitSeconds = whenMaxWaitSeconds;
 		this.whenMaxWaitSeconds = whenMaxWaitSeconds;
 	}
 	}
 
 
-	public int getWhenMaxWorkers() {
-		return whenMaxWorkers;
-	}
-
-	public void setWhenMaxWorkers(int whenMaxWorkers) {
-		this.whenMaxWorkers = whenMaxWorkers;
-	}
-
-	public int getWhenQueueLimit() {
-		return whenQueueLimit;
-	}
-
-	public void setWhenQueueLimit(int whenQueueLimit) {
-		this.whenQueueLimit = whenQueueLimit;
-	}
-
 	public ParseModeEnum getParseMode() {
 	public ParseModeEnum getParseMode() {
 		return parseMode;
 		return parseMode;
 	}
 	}
@@ -193,14 +171,6 @@ public class LiteflowProperty {
 		this.printBanner = printBanner;
 		this.printBanner = printBanner;
 	}
 	}
 
 
-	public String getThreadExecutorClass() {
-		return threadExecutorClass;
-	}
-
-	public void setThreadExecutorClass(String threadExecutorClass) {
-		this.threadExecutorClass = threadExecutorClass;
-	}
-
 	public String getNodeExecutorClass() {
 	public String getNodeExecutorClass() {
 		return nodeExecutorClass;
 		return nodeExecutorClass;
 	}
 	}
@@ -273,30 +243,6 @@ public class LiteflowProperty {
 		this.whenMaxWaitTimeUnit = whenMaxWaitTimeUnit;
 		this.whenMaxWaitTimeUnit = whenMaxWaitTimeUnit;
 	}
 	}
 
 
-	public String getParallelLoopExecutorClass() {
-		return parallelLoopExecutorClass;
-	}
-
-	public void setParallelLoopExecutorClass(String parallelLoopExecutorClass) {
-		this.parallelLoopExecutorClass = parallelLoopExecutorClass;
-	}
-
-	public int getParallelMaxWorkers() {
-		return parallelMaxWorkers;
-	}
-
-	public void setParallelMaxWorkers(int parallelMaxWorkers) {
-		this.parallelMaxWorkers = parallelMaxWorkers;
-	}
-
-	public int getParallelQueueLimit() {
-		return parallelQueueLimit;
-	}
-
-	public void setParallelQueueLimit(int parallelQueueLimit) {
-		this.parallelQueueLimit = parallelQueueLimit;
-	}
-
 	public boolean isFallbackCmpEnable() {
 	public boolean isFallbackCmpEnable() {
 		return fallbackCmpEnable;
 		return fallbackCmpEnable;
 	}
 	}
@@ -336,4 +282,40 @@ public class LiteflowProperty {
 	public void setScriptSetting(Map<String, String> scriptSetting) {
 	public void setScriptSetting(Map<String, String> scriptSetting) {
 		this.scriptSetting = scriptSetting;
 		this.scriptSetting = scriptSetting;
 	}
 	}
+
+    public Integer getGlobalThreadPoolSize() {
+        if (ObjectUtil.isNull(globalThreadPoolSize)) {
+            return 16;
+        } else {
+            return globalThreadPoolSize;
+        }
+    }
+
+    public void setGlobalThreadPoolSize(Integer globalThreadPoolSize) {
+        this.globalThreadPoolSize = globalThreadPoolSize;
+    }
+
+    public Integer getGlobalThreadPoolQueueSize() {
+        if (ObjectUtil.isNull(globalThreadPoolQueueSize)) {
+            return 512;
+        } else {
+            return globalThreadPoolQueueSize;
+        }
+    }
+
+    public void setGlobalThreadPoolQueueSize(Integer globalThreadPoolQueueSize) {
+        this.globalThreadPoolQueueSize = globalThreadPoolQueueSize;
+    }
+
+    public String getGlobalThreadPoolExecutorClass() {
+        if (StrUtil.isBlank(globalThreadPoolExecutorClass)) {
+            return "com.yomahub.liteflow.thread.LiteFlowDefaultGlobalExecutorBuilder";
+        } else {
+            return globalThreadPoolExecutorClass;
+        }
+    }
+
+    public void setGlobalThreadPoolExecutorClass(String globalThreadPoolExecutorClass) {
+        this.globalThreadPoolExecutorClass = globalThreadPoolExecutorClass;
+    }
 }
 }

+ 3 - 6
liteflow-spring-boot-starter/src/main/java/com/yomahub/liteflow/springboot/config/LiteflowPropertyAutoConfiguration.java

@@ -26,12 +26,9 @@ public class LiteflowPropertyAutoConfiguration {
 		liteflowConfig.setRuleSourceExtData(property.getRuleSourceExtData());
 		liteflowConfig.setRuleSourceExtData(property.getRuleSourceExtData());
 		liteflowConfig.setRuleSourceExtDataMap(property.getRuleSourceExtDataMap());
 		liteflowConfig.setRuleSourceExtDataMap(property.getRuleSourceExtDataMap());
 		liteflowConfig.setSlotSize(property.getSlotSize());
 		liteflowConfig.setSlotSize(property.getSlotSize());
-		liteflowConfig.setThreadExecutorClass(property.getThreadExecutorClass());
 		liteflowConfig.setWhenMaxWaitSeconds(property.getWhenMaxWaitSeconds());
 		liteflowConfig.setWhenMaxWaitSeconds(property.getWhenMaxWaitSeconds());
 		liteflowConfig.setWhenMaxWaitTime(property.getWhenMaxWaitTime());
 		liteflowConfig.setWhenMaxWaitTime(property.getWhenMaxWaitTime());
 		liteflowConfig.setWhenMaxWaitTimeUnit(property.getWhenMaxWaitTimeUnit());
 		liteflowConfig.setWhenMaxWaitTimeUnit(property.getWhenMaxWaitTimeUnit());
-		liteflowConfig.setWhenMaxWorkers(property.getWhenMaxWorkers());
-		liteflowConfig.setWhenQueueLimit(property.getWhenQueueLimit());
 		liteflowConfig.setWhenThreadPoolIsolate(property.isWhenThreadPoolIsolate());
 		liteflowConfig.setWhenThreadPoolIsolate(property.isWhenThreadPoolIsolate());
 		liteflowConfig.setParseMode(property.getParseMode());
 		liteflowConfig.setParseMode(property.getParseMode());
 		liteflowConfig.setEnable(property.isEnable());
 		liteflowConfig.setEnable(property.isEnable());
@@ -44,9 +41,6 @@ public class LiteflowPropertyAutoConfiguration {
 		liteflowConfig.setMainExecutorClass(property.getMainExecutorClass());
 		liteflowConfig.setMainExecutorClass(property.getMainExecutorClass());
 		liteflowConfig.setPrintExecutionLog(property.isPrintExecutionLog());
 		liteflowConfig.setPrintExecutionLog(property.isPrintExecutionLog());
 		liteflowConfig.setEnableMonitorFile(property.isEnableMonitorFile());
 		liteflowConfig.setEnableMonitorFile(property.isEnableMonitorFile());
-		liteflowConfig.setParallelMaxWorkers(property.getParallelMaxWorkers());
-		liteflowConfig.setParallelQueueLimit(property.getParallelQueueLimit());
-		liteflowConfig.setParallelLoopExecutorClass(property.getParallelLoopExecutorClass());
 		liteflowConfig.setFallbackCmpEnable(property.isFallbackCmpEnable());
 		liteflowConfig.setFallbackCmpEnable(property.isFallbackCmpEnable());
 		liteflowConfig.setFastLoad(property.isFastLoad());
 		liteflowConfig.setFastLoad(property.isFastLoad());
 		liteflowConfig.setEnableLog(liteflowMonitorProperty.isEnableLog());
 		liteflowConfig.setEnableLog(liteflowMonitorProperty.isEnableLog());
@@ -54,6 +48,9 @@ public class LiteflowPropertyAutoConfiguration {
 		liteflowConfig.setDelay(liteflowMonitorProperty.getDelay());
 		liteflowConfig.setDelay(liteflowMonitorProperty.getDelay());
 		liteflowConfig.setPeriod(liteflowMonitorProperty.getPeriod());
 		liteflowConfig.setPeriod(liteflowMonitorProperty.getPeriod());
 		liteflowConfig.setScriptSetting(property.getScriptSetting());
 		liteflowConfig.setScriptSetting(property.getScriptSetting());
+        liteflowConfig.setGlobalThreadPoolExecutorClass(property.getGlobalThreadPoolExecutorClass());
+        liteflowConfig.setGlobalThreadPoolQueueSize(property.getGlobalThreadPoolQueueSize());
+        liteflowConfig.setGlobalThreadPoolSize(property.getGlobalThreadPoolSize());
 		return liteflowConfig;
 		return liteflowConfig;
 	}
 	}
 
 

+ 13 - 34
liteflow-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json

@@ -61,13 +61,6 @@
       "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
       "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
       "defaultValue": "com.yomahub.liteflow.thread.LiteFlowDefaultMainExecutorBuilder"
       "defaultValue": "com.yomahub.liteflow.thread.LiteFlowDefaultMainExecutorBuilder"
     },
     },
-    {
-      "name": "liteflow.thread-executor-class",
-      "type": "java.lang.String",
-      "description": "Custom thread pool implement for when executor.",
-      "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
-      "defaultValue": "com.yomahub.liteflow.thread.LiteFlowDefaultWhenExecutorBuilder"
-    },
     {
     {
       "name": "liteflow.when-max-wait-seconds",
       "name": "liteflow.when-max-wait-seconds",
       "type": "java.lang.Integer",
       "type": "java.lang.Integer",
@@ -89,20 +82,6 @@
       "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
       "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
       "defaultValue": "MILLISECONDS"
       "defaultValue": "MILLISECONDS"
     },
     },
-    {
-      "name": "liteflow.when-max-workers",
-      "type": "java.lang.Integer",
-      "description": "Set the async thread pool worker max-size on \" when \" mode.",
-      "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
-      "defaultValue": 16
-    },
-    {
-      "name": "liteflow.when-queue-limit",
-      "type": "java.lang.Integer",
-      "description": "Set the async thread pool queue max-size on \" when \" mode.",
-      "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
-      "defaultValue": 512
-    },
     {
     {
       "name": "liteflow.when-thread-pool-isolate",
       "name": "liteflow.when-thread-pool-isolate",
       "type": "java.lang.Boolean",
       "type": "java.lang.Boolean",
@@ -195,31 +174,31 @@
       "defaultValue": false
       "defaultValue": false
     },
     },
     {
     {
-      "name": "liteflow.parallel-max-workers",
+      "name": "liteflow.script-setting",
+      "type": "java.util.Map",
+      "description": "script special settings.",
+      "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty"
+    },
+    {
+      "name": "liteflow.global-thread-pool-size",
       "type": "java.lang.Integer",
       "type": "java.lang.Integer",
-      "description": "Set the async thread pool worker max-size on \" parallel-loop \" mode.",
+      "description": "Set the global chain thread pool worker max-size.",
       "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
       "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
       "defaultValue": 16
       "defaultValue": 16
     },
     },
     {
     {
-      "name": "liteflow.parallel-queue-limit",
+      "name": "liteflow.global-thread-pool-queue-size",
       "type": "java.lang.Integer",
       "type": "java.lang.Integer",
-      "description": "Set the async thread pool queue max-size on \" parallel-loop \" mode.",
+      "description": "Set the global chain thread pool queue max-size ",
       "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
       "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
       "defaultValue": 512
       "defaultValue": 512
     },
     },
     {
     {
-      "name": "liteflow.parallel-loop-executor-class",
+      "name": "liteflow.global-thread-pool-executor-class",
       "type": "java.lang.String",
       "type": "java.lang.String",
-      "description": "Custom thread pool implement for parallel-loop executor.",
+      "description": "Custom the global chain thread pool implement for global chain executor.",
       "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
       "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty",
-      "defaultValue": "com.yomahub.liteflow.thread.LiteFlowDefaultParallelLoopExecutorBuilder"
-    },
-    {
-      "name": "liteflow.script-setting",
-      "type": "java.util.Map",
-      "description": "script special settings.",
-      "sourceType": "com.yomahub.liteflow.springboot.LiteflowProperty"
+      "defaultValue": "com.yomahub.liteflow.thread.LiteFlowDefaultGlobalExecutorBuilder"
     }
     }
   ]
   ]
 }
 }

+ 3 - 6
liteflow-spring-boot-starter/src/main/resources/META-INF/liteflow-default.properties

@@ -4,11 +4,8 @@ liteflow.slot-size=1024
 liteflow.main-executor-works=64
 liteflow.main-executor-works=64
 liteflow.main-executor-class=com.yomahub.liteflow.thread.LiteFlowDefaultMainExecutorBuilder
 liteflow.main-executor-class=com.yomahub.liteflow.thread.LiteFlowDefaultMainExecutorBuilder
 liteflow.request-id-generator-class=com.yomahub.liteflow.flow.id.DefaultRequestIdGenerator
 liteflow.request-id-generator-class=com.yomahub.liteflow.flow.id.DefaultRequestIdGenerator
-liteflow.thread-executor-class=com.yomahub.liteflow.thread.LiteFlowDefaultWhenExecutorBuilder
 liteflow.when-max-wait-time=15000
 liteflow.when-max-wait-time=15000
 liteflow.when-max-wait-time-unit=MILLISECONDS
 liteflow.when-max-wait-time-unit=MILLISECONDS
-liteflow.when-max-workers=16
-liteflow.when-queue-limit=512
 liteflow.when-thread-pool-isolate=false
 liteflow.when-thread-pool-isolate=false
 liteflow.parse-mode=PARSE_ALL_ON_START
 liteflow.parse-mode=PARSE_ALL_ON_START
 liteflow.retry-count=0
 liteflow.retry-count=0
@@ -18,12 +15,12 @@ liteflow.print-execution-log=true
 liteflow.fallback-cmp-enable=false
 liteflow.fallback-cmp-enable=false
 liteflow.fast-load=false
 liteflow.fast-load=false
 liteflow.check-node-exists=true
 liteflow.check-node-exists=true
-liteflow.parallel-max-workers=16
-liteflow.parallel-queue-limit=512
-liteflow.parallel-loop-executor-class=com.yomahub.liteflow.thread.LiteFlowDefaultParallelLoopExecutorBuilder
 liteflow.monitor.enable-log=false
 liteflow.monitor.enable-log=false
 liteflow.monitor.queue-limit=200
 liteflow.monitor.queue-limit=200
 liteflow.monitor.delay=300000
 liteflow.monitor.delay=300000
 liteflow.monitor.period=300000
 liteflow.monitor.period=300000
 liteflow.enable-monitor-file=false
 liteflow.enable-monitor-file=false
+liteflow.global-thread-pool-size=16
+liteflow.global-thread-pool-queue-size=512
+liteflow.global-thread-pool-executor-class=com.yomahub.liteflow.thread.LiteFlowDefaultGlobalExecutorBuilder
 
 

+ 2 - 2
liteflow-testcase-el/liteflow-testcase-el-builder/src/test/java/com/yomahub/liteflow/test/builder/customTreadExecutor/CustomThreadExecutor1.java

@@ -22,8 +22,8 @@ public class CustomThreadExecutor1 implements ExecutorBuilder {
 		if (ObjectUtil.isNull(liteflowConfig)) {
 		if (ObjectUtil.isNull(liteflowConfig)) {
 			liteflowConfig = new LiteflowConfig();
 			liteflowConfig = new LiteflowConfig();
 		}
 		}
-		return buildDefaultExecutor(liteflowConfig.getWhenMaxWorkers(), liteflowConfig.getWhenMaxWorkers(),
-				liteflowConfig.getWhenQueueLimit(), "customer-when-1-thead-");
+		return buildDefaultExecutor(liteflowConfig.getGlobalThreadPoolSize(), liteflowConfig.getGlobalThreadPoolSize(),
+									liteflowConfig.getGlobalThreadPoolQueueSize(), "customer-when-1-thead-");
 	}
 	}
 
 
 }
 }

+ 72 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/java/com/yomahub/liteflow/test/chainThreadPool/ChainThreadPoolELSpringbootTest.java

@@ -0,0 +1,72 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.collection.ListUtil;
+import com.yomahub.liteflow.core.FlowExecutor;
+import com.yomahub.liteflow.flow.LiteflowResponse;
+import com.yomahub.liteflow.slot.DefaultContext;
+import com.yomahub.liteflow.test.BaseTest;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.noear.solon.annotation.Import;
+import org.noear.solon.annotation.Inject;
+import org.noear.solon.test.SolonTest;
+
+import java.util.List;
+
+/**
+ * springboot环境下chain线程池隔离测试
+ */
+@SolonTest
+@Import(profiles = "classpath:/chainThreadPool/application.properties")
+public class ChainThreadPoolELSpringbootTest extends BaseTest {
+
+
+    @Inject
+    private FlowExecutor flowExecutor;
+
+    /**
+     * 测试WHEN上全局线程池和chain线程池隔离-优先以chain上为准
+     */
+    @Test
+    public void testChainThreadPool() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-chain-thead"));
+    }
+
+    /**
+     * 测试FOR上全局线程池和chain线程池隔离-优先以chain上为准
+     */
+    @Test
+    public void testChainThreadPool2() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain2", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-chain-thead"));
+    }
+
+    /**
+     * 测试WHILE上全局线程池和chain线程池隔离-优先以chain上为准
+     */
+    @Test
+    public void testChainThreadPool3() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain3", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-chain-thead"));
+    }
+
+    /**
+     * 测试ITERATOR上全局线程池和chain线程池隔离-优先以chain上为准
+     */
+    @Test
+    public void testChainThreadPool4() {
+        List<String> list = ListUtil.toList("1", "2", "3", "4", "5");
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain4", list);
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-chain-thead"));
+    }
+
+}

+ 73 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/java/com/yomahub/liteflow/test/chainThreadPool/ConditionThreadPoolELSpringbootTest.java

@@ -0,0 +1,73 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.collection.ListUtil;
+import com.yomahub.liteflow.core.FlowExecutor;
+import com.yomahub.liteflow.flow.LiteflowResponse;
+import com.yomahub.liteflow.slot.DefaultContext;
+import com.yomahub.liteflow.test.BaseTest;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.noear.solon.annotation.Import;
+import org.noear.solon.annotation.Inject;
+import org.noear.solon.test.SolonTest;
+
+import java.util.List;
+
+/**
+ * springboot环境下chain线程池隔离测试
+ */
+
+@SolonTest
+@Import(profiles = "classpath:/chainThreadPool/application2.properties")
+public class ConditionThreadPoolELSpringbootTest extends BaseTest {
+
+
+    @Inject
+    private FlowExecutor flowExecutor;
+
+    /**
+     * 测试WEHN上condition线程池和chain线程池隔离-优先以WHEN上为准
+     */
+    @Test
+    public void testConditionThreadPool() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-when-thead"));
+    }
+
+    /**
+     * 测试FOR上condition线程池和chain线程池隔离-优先以FOR上为准
+     */
+    @Test
+    public void testConditionThreadPool2() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain2", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-loop-thead"));
+    }
+
+    /**
+     * 测试WHILE上condition线程池和chain线程池隔离-优先以WHILE上为准
+     */
+    @Test
+    public void testConditionThreadPool3() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain3", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-loop-thead"));
+    }
+
+    /**
+     * 测试ITERATOR上condition线程池和chain线程池隔离-优先以ITERATOR上为准
+     */
+    @Test
+    public void testConditionThreadPool4() {
+        List<String> list = ListUtil.toList("1", "2", "3", "4", "5");
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain4", list);
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-loop-thead"));
+    }
+
+}

+ 23 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomChainThreadExecutor.java

@@ -0,0 +1,23 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.yomahub.liteflow.property.LiteflowConfig;
+import com.yomahub.liteflow.property.LiteflowConfigGetter;
+import com.yomahub.liteflow.thread.ExecutorBuilder;
+
+import java.util.concurrent.ExecutorService;
+
+public class CustomChainThreadExecutor implements ExecutorBuilder {
+
+    @Override
+    public ExecutorService buildExecutor() {
+        LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
+        // 只有在非spring的场景下liteflowConfig才会为null
+        if (ObjectUtil.isNull(liteflowConfig)) {
+            liteflowConfig = new LiteflowConfig();
+        }
+        return buildDefaultExecutor(16, 16,
+                                    512, "customer-chain-thead");
+    }
+
+}

+ 23 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomGlobalThreadExecutor.java

@@ -0,0 +1,23 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.yomahub.liteflow.property.LiteflowConfig;
+import com.yomahub.liteflow.property.LiteflowConfigGetter;
+import com.yomahub.liteflow.thread.ExecutorBuilder;
+
+import java.util.concurrent.ExecutorService;
+
+public class CustomGlobalThreadExecutor implements ExecutorBuilder {
+
+    @Override
+    public ExecutorService buildExecutor() {
+        LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
+        // 只有在非spring的场景下liteflowConfig才会为null
+        if (ObjectUtil.isNull(liteflowConfig)) {
+            liteflowConfig = new LiteflowConfig();
+        }
+        return buildDefaultExecutor(16, 16,
+                                    512, "customer-global-thead");
+    }
+
+}

+ 23 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomLoopThreadExecutor.java

@@ -0,0 +1,23 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.yomahub.liteflow.property.LiteflowConfig;
+import com.yomahub.liteflow.property.LiteflowConfigGetter;
+import com.yomahub.liteflow.thread.ExecutorBuilder;
+
+import java.util.concurrent.ExecutorService;
+
+public class CustomLoopThreadExecutor implements ExecutorBuilder {
+
+    @Override
+    public ExecutorService buildExecutor() {
+        LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
+        // 只有在非spring的场景下liteflowConfig才会为null
+        if (ObjectUtil.isNull(liteflowConfig)) {
+            liteflowConfig = new LiteflowConfig();
+        }
+        return buildDefaultExecutor(16, 16,
+                                    512, "customer-loop-thead");
+    }
+
+}

+ 23 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomWhenThreadExecutor.java

@@ -0,0 +1,23 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.yomahub.liteflow.property.LiteflowConfig;
+import com.yomahub.liteflow.property.LiteflowConfigGetter;
+import com.yomahub.liteflow.thread.ExecutorBuilder;
+
+import java.util.concurrent.ExecutorService;
+
+public class CustomWhenThreadExecutor implements ExecutorBuilder {
+
+    @Override
+    public ExecutorService buildExecutor() {
+        LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
+        // 只有在非spring的场景下liteflowConfig才会为null
+        if (ObjectUtil.isNull(liteflowConfig)) {
+            liteflowConfig = new LiteflowConfig();
+        }
+        return buildDefaultExecutor(16, 16,
+                                    512, "customer-when-thead");
+    }
+
+}

+ 71 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/java/com/yomahub/liteflow/test/chainThreadPool/GlobalThreadPoolELSpringbootTest.java

@@ -0,0 +1,71 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.collection.ListUtil;
+import com.yomahub.liteflow.core.FlowExecutor;
+import com.yomahub.liteflow.flow.LiteflowResponse;
+import com.yomahub.liteflow.slot.DefaultContext;
+import com.yomahub.liteflow.test.BaseTest;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.noear.solon.annotation.Import;
+import org.noear.solon.annotation.Inject;
+import org.noear.solon.test.SolonTest;
+
+import java.util.List;
+
+/**
+ * springboot环境下Global线程池隔离测试
+ */
+@SolonTest
+@Import(profiles = "classpath:/chainThreadPool/application3.properties")
+public class GlobalThreadPoolELSpringbootTest extends BaseTest {
+
+    @Inject
+    private FlowExecutor flowExecutor;
+
+    /**
+     * 测试WHEN上全局线程池
+     */
+    @Test
+    public void testGlobalThreadPool() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-global-thead"));
+    }
+
+    /**
+     * 测试FOR上全局线程池
+     */
+    @Test
+    public void testGlobalThreadPool2() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain2", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-global-thead"));
+    }
+
+    /**
+     * 测试WHILE上全局线程池
+     */
+    @Test
+    public void testGlobalThreadPool3() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain3", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-global-thead"));
+    }
+
+    /**
+     * 测试ITERATOR上全局线程池
+     */
+    @Test
+    public void testGlobalThreadPool4() {
+        List<String> list = ListUtil.toList("1", "2", "3", "4", "5");
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain4", list);
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-global-thead"));
+    }
+
+}

+ 81 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/CmpConfig.java

@@ -0,0 +1,81 @@
+package com.yomahub.liteflow.test.chainThreadPool.cmp;
+
+import com.yomahub.liteflow.annotation.LiteflowComponent;
+import com.yomahub.liteflow.annotation.LiteflowMethod;
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
+import com.yomahub.liteflow.enums.NodeTypeEnum;
+import com.yomahub.liteflow.slot.DefaultContext;
+
+import java.util.Iterator;
+import java.util.List;
+
+@LiteflowComponent
+public class CmpConfig {
+
+	@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "a")
+	public void processA(NodeComponent bindCmp) {
+
+		System.out.println("ACmp executed!");
+	}
+
+	@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "b")
+	public void processB(NodeComponent bindCmp) {
+		DefaultContext context = bindCmp.getFirstContextBean();
+		context.setData("threadName", Thread.currentThread().getName());
+		System.out.println("BCmp executed!");
+	}
+
+
+	@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "d")
+	public void processD(NodeComponent bindCmp) {
+		DefaultContext context = bindCmp.getFirstContextBean();
+		String key = "test";
+		if (context.hasData(key)) {
+			int count = context.getData(key);
+			context.setData(key, ++count);
+		} else {
+			context.setData(key, 1);
+		}
+	}
+
+	@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "f")
+	public void processE(NodeComponent bindCmp) {
+		DefaultContext context = bindCmp.getFirstContextBean();
+		context.setData("threadName", Thread.currentThread().getName());
+		System.out.println("FCmp executed!");
+	}
+
+	@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "i")
+	public void processI(NodeComponent bindCmp) {
+		DefaultContext context = bindCmp.getFirstContextBean();
+		context.setData("threadName", Thread.currentThread().getName());
+		System.out.println("ICmp executed!");
+	}
+
+	@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_ITERATOR, nodeId = "it", nodeType = NodeTypeEnum.ITERATOR)
+	public Iterator<String> processIT(NodeComponent bindCmp) {
+		List<String> list = bindCmp.getRequestData();
+		return list.iterator();
+	}
+
+	@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "w")
+	public void processW(NodeComponent bindCmp) {
+		DefaultContext context = bindCmp.getFirstContextBean();
+		context.setData("threadName", Thread.currentThread().getName());
+		System.out.println("WCmp executed!");
+	}
+
+	@LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_BOOLEAN, nodeId = "z", nodeType = NodeTypeEnum.BOOLEAN)
+	public boolean processZ(NodeComponent bindCmp) {
+		DefaultContext context = bindCmp.getFirstContextBean();
+		String key = "test";
+		if (context.hasData(key)) {
+			int count = context.getData("test");
+			return count < 5;
+		} else {
+			return true;
+		}
+	}
+
+}

+ 2 - 2
liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomThreadExecutor1.java

@@ -16,8 +16,8 @@ public class CustomThreadExecutor1 implements ExecutorBuilder {
 		if (ObjectUtil.isNull(liteflowConfig)) {
 		if (ObjectUtil.isNull(liteflowConfig)) {
 			liteflowConfig = new LiteflowConfig();
 			liteflowConfig = new LiteflowConfig();
 		}
 		}
-		return buildDefaultExecutor(liteflowConfig.getWhenMaxWorkers(), liteflowConfig.getWhenMaxWorkers(),
-				liteflowConfig.getWhenQueueLimit(), "customer-when-1-thead-");
+		return buildDefaultExecutor(liteflowConfig.getGlobalThreadPoolSize(), liteflowConfig.getGlobalThreadPoolSize(),
+									liteflowConfig.getGlobalThreadPoolQueueSize(), "customer-when-1-thead-");
 	}
 	}
 
 
 }
 }

+ 2 - 2
liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomThreadExecutor2.java

@@ -16,8 +16,8 @@ public class CustomThreadExecutor2 implements ExecutorBuilder {
 		if (ObjectUtil.isNull(liteflowConfig)) {
 		if (ObjectUtil.isNull(liteflowConfig)) {
 			liteflowConfig = new LiteflowConfig();
 			liteflowConfig = new LiteflowConfig();
 		}
 		}
-		return buildDefaultExecutor(liteflowConfig.getWhenMaxWorkers(), liteflowConfig.getWhenMaxWorkers(),
-				liteflowConfig.getWhenQueueLimit(), "customer-when-2-thead-");
+		return buildDefaultExecutor(liteflowConfig.getGlobalThreadPoolSize(), liteflowConfig.getGlobalThreadPoolSize(),
+									liteflowConfig.getGlobalThreadPoolQueueSize(), "customer-when-2-thead-");
 	}
 	}
 
 
 }
 }

+ 2 - 2
liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomThreadExecutor3.java

@@ -16,8 +16,8 @@ public class CustomThreadExecutor3 implements ExecutorBuilder {
 		if (ObjectUtil.isNull(liteflowConfig)) {
 		if (ObjectUtil.isNull(liteflowConfig)) {
 			liteflowConfig = new LiteflowConfig();
 			liteflowConfig = new LiteflowConfig();
 		}
 		}
-		return buildDefaultExecutor(liteflowConfig.getWhenMaxWorkers(), liteflowConfig.getWhenMaxWorkers(),
-				liteflowConfig.getWhenQueueLimit(), "customer-when-3-thead-");
+		return buildDefaultExecutor(liteflowConfig.getGlobalThreadPoolSize(), liteflowConfig.getGlobalThreadPoolSize(),
+									liteflowConfig.getGlobalThreadPoolQueueSize(), "customer-when-3-thead-");
 	}
 	}
 
 
 }
 }

+ 1 - 1
liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolELDeclMultiSpringbootTest.java

@@ -35,7 +35,7 @@ public class CustomWhenThreadPoolELDeclMultiSpringbootTest extends BaseTest {
 		LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg");
 		LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg");
 		DefaultContext context = response.getFirstContextBean();
 		DefaultContext context = response.getFirstContextBean();
 		Assertions.assertTrue(response.isSuccess());
 		Assertions.assertTrue(response.isSuccess());
-		Assertions.assertTrue(context.getData("threadName").toString().startsWith("when-thread-1"));
+		Assertions.assertTrue(context.getData("threadName").toString().startsWith("global-thread-1"));
 	}
 	}
 
 
 	/**
 	/**

+ 2 - 2
liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/java/com/yomahub/liteflow/test/parallelLoop/CustomThreadExecutor.java

@@ -16,8 +16,8 @@ public class CustomThreadExecutor implements ExecutorBuilder {
 		if (ObjectUtil.isNull(liteflowConfig)) {
 		if (ObjectUtil.isNull(liteflowConfig)) {
 			liteflowConfig = new LiteflowConfig();
 			liteflowConfig = new LiteflowConfig();
 		}
 		}
-		return buildDefaultExecutor(liteflowConfig.getParallelMaxWorkers(), liteflowConfig.getParallelMaxWorkers(),
-				liteflowConfig.getParallelQueueLimit(), "customer-loop-thead-");
+		return buildDefaultExecutor(liteflowConfig.getGlobalThreadPoolSize(), liteflowConfig.getGlobalThreadPoolSize(),
+									liteflowConfig.getGlobalThreadPoolQueueSize(), "customer-loop-thead-");
 	}
 	}
 
 
 }
 }

+ 1 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/resources/chainThreadPool/application.properties

@@ -0,0 +1 @@
+liteflow.rule-source=chainThreadPool/flow.el.xml

+ 2 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/resources/chainThreadPool/application2.properties

@@ -0,0 +1,2 @@
+liteflow.rule-source=chainThreadPool/flow2.el.xml
+liteflow.when-thread-pool-isolate=true

+ 4 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/resources/chainThreadPool/application3.properties

@@ -0,0 +1,4 @@
+liteflow.rule-source=chainThreadPool/flow3.el.xml
+liteflow.global-thread-pool-size=16
+liteflow.global-thread-pool-queue-size=512
+liteflow.global-thread-pool-executor-class=com.yomahub.liteflow.test.chainThreadPool.CustomGlobalThreadExecutor

+ 22 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/resources/chainThreadPool/flow.el.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<flow>
+    <chain name="chain1"
+           thread-pool-executor-class="com.yomahub.liteflow.test.chainThreadPool.CustomChainThreadExecutor">
+        WHEN(a,b);
+    </chain>
+
+    <chain name="chain2"
+           thread-pool-executor-class="com.yomahub.liteflow.test.chainThreadPool.CustomChainThreadExecutor">
+        FOR(5).parallel(true).DO(THEN(a,f));
+    </chain>
+
+    <chain name="chain3"
+           thread-pool-executor-class="com.yomahub.liteflow.test.chainThreadPool.CustomChainThreadExecutor">
+        WHILE(z).parallel(true).DO(THEN(w,d));
+    </chain>
+
+    <chain name="chain4"
+           thread-pool-executor-class="com.yomahub.liteflow.test.chainThreadPool.CustomChainThreadExecutor">
+        ITERATOR(it).parallel(true).DO(THEN(a,i));
+    </chain>
+</flow>

+ 22 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/resources/chainThreadPool/flow2.el.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<flow>
+    <chain name="chain1"
+           thread-pool-executor-class="com.yomahub.liteflow.test.chainThreadPool.CustomChainThreadExecutor">
+        WHEN(a,b).threadPool("com.yomahub.liteflow.test.chainThreadPool.CustomWhenThreadExecutor");
+    </chain>
+
+    <chain name="chain2"
+           thread-pool-executor-class="com.yomahub.liteflow.test.chainThreadPool.CustomChainThreadExecutor">
+        FOR(5).parallel(true).DO(THEN(a,f)).threadPool("com.yomahub.liteflow.test.chainThreadPool.CustomLoopThreadExecutor");
+    </chain>
+
+    <chain name="chain3"
+           thread-pool-executor-class="com.yomahub.liteflow.test.chainThreadPool.CustomChainThreadExecutor">
+        WHILE(z).parallel(true).DO(THEN(w,d)).threadPool("com.yomahub.liteflow.test.chainThreadPool.CustomLoopThreadExecutor");
+    </chain>
+
+    <chain name="chain4"
+           thread-pool-executor-class="com.yomahub.liteflow.test.chainThreadPool.CustomChainThreadExecutor">
+        ITERATOR(it).parallel(true).DO(THEN(a,i)).threadPool("com.yomahub.liteflow.test.chainThreadPool.CustomLoopThreadExecutor");
+    </chain>
+</flow>

+ 19 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/resources/chainThreadPool/flow3.el.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<flow>
+    <chain name="chain1">
+        WHEN(a,b);
+    </chain>
+
+    <chain name="chain2">
+        FOR(5).parallel(true).DO(THEN(a,f)
+        );
+    </chain>
+
+    <chain name="chain3">
+        WHILE(z).parallel(true).DO(THEN(w,d));
+    </chain>
+
+    <chain name="chain4">
+        ITERATOR(it).parallel(true).DO(THEN(a,i));
+    </chain>
+</flow>

+ 3 - 3
liteflow-testcase-el/liteflow-testcase-el-declare-multi-solon/src/test/resources/parallelLoop/application.properties

@@ -1,4 +1,4 @@
 liteflow.rule-source=parallelLoop/flow.xml
 liteflow.rule-source=parallelLoop/flow.xml
-liteflow.parallel-max-workers = 10
-liteflow.parallel-queue-limit = 1024
-liteflow.parallel-loop-executor-class =com.yomahub.liteflow.test.parallelLoop.CustomThreadExecutor
+liteflow.global-thread-pool-size=16
+liteflow.global-thread-pool-queue-size=512
+liteflow.global-thread-pool-executor-class=com.yomahub.liteflow.test.parallelLoop.CustomThreadExecutor

+ 79 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/ChainThreadPoolELSpringbootTest.java

@@ -0,0 +1,79 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.collection.ListUtil;
+import com.yomahub.liteflow.core.FlowExecutor;
+import com.yomahub.liteflow.flow.LiteflowResponse;
+import com.yomahub.liteflow.slot.DefaultContext;
+import com.yomahub.liteflow.test.BaseTest;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.test.context.TestPropertySource;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * springboot环境下chain线程池隔离测试
+ */
+@TestPropertySource(value = "classpath:/chainThreadPool/application.properties")
+@SpringBootTest(classes = ChainThreadPoolELSpringbootTest.class)
+@EnableAutoConfiguration
+@ComponentScan({"com.yomahub.liteflow.test.chainThreadPool.cmp"})
+public class ChainThreadPoolELSpringbootTest extends BaseTest {
+
+    private final Logger log = LoggerFactory.getLogger(this.getClass());
+
+    @Resource
+    private FlowExecutor flowExecutor;
+
+    /**
+     * 测试WHEN上全局线程池和chain线程池隔离-优先以chain上为准
+     */
+    @Test
+    public void testChainThreadPool() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-chain-thead"));
+    }
+
+    /**
+     * 测试FOR上全局线程池和chain线程池隔离-优先以chain上为准
+     */
+    @Test
+    public void testChainThreadPool2() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain2", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-chain-thead"));
+    }
+
+    /**
+     * 测试WHILE上全局线程池和chain线程池隔离-优先以chain上为准
+     */
+    @Test
+    public void testChainThreadPool3() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain3", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-chain-thead"));
+    }
+
+    /**
+     * 测试ITERATOR上全局线程池和chain线程池隔离-优先以chain上为准
+     */
+    @Test
+    public void testChainThreadPool4() {
+        List<String> list = ListUtil.toList("1", "2", "3", "4", "5");
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain4", list);
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-chain-thead"));
+    }
+
+}

+ 79 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/ConditionThreadPoolELSpringbootTest.java

@@ -0,0 +1,79 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.collection.ListUtil;
+import com.yomahub.liteflow.core.FlowExecutor;
+import com.yomahub.liteflow.flow.LiteflowResponse;
+import com.yomahub.liteflow.slot.DefaultContext;
+import com.yomahub.liteflow.test.BaseTest;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.test.context.TestPropertySource;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * springboot环境下chain线程池隔离测试
+ */
+@TestPropertySource(value = "classpath:/chainThreadPool/application2.properties")
+@SpringBootTest(classes = ConditionThreadPoolELSpringbootTest.class)
+@EnableAutoConfiguration
+@ComponentScan({"com.yomahub.liteflow.test.chainThreadPool.cmp"})
+public class ConditionThreadPoolELSpringbootTest extends BaseTest {
+
+    private final Logger log = LoggerFactory.getLogger(this.getClass());
+
+    @Resource
+    private FlowExecutor flowExecutor;
+
+    /**
+     * 测试WEHN上condition线程池和chain线程池隔离-优先以WHEN上为准
+     */
+    @Test
+    public void testConditionThreadPool() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-when-thead"));
+    }
+
+    /**
+     * 测试FOR上condition线程池和chain线程池隔离-优先以FOR上为准
+     */
+    @Test
+    public void testConditionThreadPool2() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain2", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-loop-thead"));
+    }
+
+    /**
+     * 测试WHILE上condition线程池和chain线程池隔离-优先以WHILE上为准
+     */
+    @Test
+    public void testConditionThreadPool3() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain3", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-loop-thead"));
+    }
+
+    /**
+     * 测试ITERATOR上condition线程池和chain线程池隔离-优先以ITERATOR上为准
+     */
+    @Test
+    public void testConditionThreadPool4() {
+        List<String> list = ListUtil.toList("1", "2", "3", "4", "5");
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain4", list);
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-loop-thead"));
+    }
+
+}

+ 23 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomChainThreadExecutor.java

@@ -0,0 +1,23 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.yomahub.liteflow.property.LiteflowConfig;
+import com.yomahub.liteflow.property.LiteflowConfigGetter;
+import com.yomahub.liteflow.thread.ExecutorBuilder;
+
+import java.util.concurrent.ExecutorService;
+
+public class CustomChainThreadExecutor implements ExecutorBuilder {
+
+    @Override
+    public ExecutorService buildExecutor() {
+        LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
+        // 只有在非spring的场景下liteflowConfig才会为null
+        if (ObjectUtil.isNull(liteflowConfig)) {
+            liteflowConfig = new LiteflowConfig();
+        }
+        return buildDefaultExecutor(16, 16,
+                                    512, "customer-chain-thead");
+    }
+
+}

+ 23 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomGlobalThreadExecutor.java

@@ -0,0 +1,23 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.yomahub.liteflow.property.LiteflowConfig;
+import com.yomahub.liteflow.property.LiteflowConfigGetter;
+import com.yomahub.liteflow.thread.ExecutorBuilder;
+
+import java.util.concurrent.ExecutorService;
+
+public class CustomGlobalThreadExecutor implements ExecutorBuilder {
+
+    @Override
+    public ExecutorService buildExecutor() {
+        LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
+        // 只有在非spring的场景下liteflowConfig才会为null
+        if (ObjectUtil.isNull(liteflowConfig)) {
+            liteflowConfig = new LiteflowConfig();
+        }
+        return buildDefaultExecutor(16, 16,
+                                    512, "customer-global-thead");
+    }
+
+}

+ 23 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomLoopThreadExecutor.java

@@ -0,0 +1,23 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.yomahub.liteflow.property.LiteflowConfig;
+import com.yomahub.liteflow.property.LiteflowConfigGetter;
+import com.yomahub.liteflow.thread.ExecutorBuilder;
+
+import java.util.concurrent.ExecutorService;
+
+public class CustomLoopThreadExecutor implements ExecutorBuilder {
+
+    @Override
+    public ExecutorService buildExecutor() {
+        LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
+        // 只有在非spring的场景下liteflowConfig才会为null
+        if (ObjectUtil.isNull(liteflowConfig)) {
+            liteflowConfig = new LiteflowConfig();
+        }
+        return buildDefaultExecutor(16, 16,
+                                    512, "customer-loop-thead");
+    }
+
+}

+ 23 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomWhenThreadExecutor.java

@@ -0,0 +1,23 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.yomahub.liteflow.property.LiteflowConfig;
+import com.yomahub.liteflow.property.LiteflowConfigGetter;
+import com.yomahub.liteflow.thread.ExecutorBuilder;
+
+import java.util.concurrent.ExecutorService;
+
+public class CustomWhenThreadExecutor implements ExecutorBuilder {
+
+    @Override
+    public ExecutorService buildExecutor() {
+        LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
+        // 只有在非spring的场景下liteflowConfig才会为null
+        if (ObjectUtil.isNull(liteflowConfig)) {
+            liteflowConfig = new LiteflowConfig();
+        }
+        return buildDefaultExecutor(16, 16,
+                                    512, "customer-when-thead");
+    }
+
+}

+ 79 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/GlobalThreadPoolELSpringbootTest.java

@@ -0,0 +1,79 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.collection.ListUtil;
+import com.yomahub.liteflow.core.FlowExecutor;
+import com.yomahub.liteflow.flow.LiteflowResponse;
+import com.yomahub.liteflow.slot.DefaultContext;
+import com.yomahub.liteflow.test.BaseTest;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.test.context.TestPropertySource;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * springboot环境下Global线程池隔离测试
+ */
+@TestPropertySource(value = "classpath:/chainThreadPool/application3.properties")
+@SpringBootTest(classes = GlobalThreadPoolELSpringbootTest.class)
+@EnableAutoConfiguration
+@ComponentScan({"com.yomahub.liteflow.test.chainThreadPool.cmp"})
+public class GlobalThreadPoolELSpringbootTest extends BaseTest {
+
+    private final Logger log = LoggerFactory.getLogger(this.getClass());
+
+    @Resource
+    private FlowExecutor flowExecutor;
+
+    /**
+     * 测试WHEN上全局线程池
+     */
+    @Test
+    public void testGlobalThreadPool() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-global-thead"));
+    }
+
+    /**
+     * 测试FOR上全局线程池
+     */
+    @Test
+    public void testGlobalThreadPool2() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain2", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-global-thead"));
+    }
+
+    /**
+     * 测试WHILE上全局线程池
+     */
+    @Test
+    public void testGlobalThreadPool3() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain3", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-global-thead"));
+    }
+
+    /**
+     * 测试ITERATOR上全局线程池
+     */
+    @Test
+    public void testGlobalThreadPool4() {
+        List<String> list = ListUtil.toList("1", "2", "3", "4", "5");
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain4", list);
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-global-thead"));
+    }
+
+}

+ 81 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/CmpConfig.java

@@ -0,0 +1,81 @@
+package com.yomahub.liteflow.test.chainThreadPool.cmp;
+
+import com.yomahub.liteflow.annotation.LiteflowComponent;
+import com.yomahub.liteflow.annotation.LiteflowMethod;
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
+import com.yomahub.liteflow.enums.NodeTypeEnum;
+import com.yomahub.liteflow.slot.DefaultContext;
+
+import java.util.Iterator;
+import java.util.List;
+
+@LiteflowComponent
+public class CmpConfig {
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "a")
+    public void processA(NodeComponent bindCmp) {
+
+        System.out.println("ACmp executed!");
+    }
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "b")
+    public void processB(NodeComponent bindCmp) {
+        DefaultContext context = bindCmp.getFirstContextBean();
+        context.setData("threadName", Thread.currentThread().getName());
+        System.out.println("BCmp executed!");
+    }
+
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "d")
+    public void processD(NodeComponent bindCmp) {
+        DefaultContext context = bindCmp.getFirstContextBean();
+        String key = "test";
+        if (context.hasData(key)) {
+            int count = context.getData(key);
+            context.setData(key, ++count);
+        } else {
+            context.setData(key, 1);
+        }
+    }
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "f")
+    public void processE(NodeComponent bindCmp) {
+        DefaultContext context = bindCmp.getFirstContextBean();
+        context.setData("threadName", Thread.currentThread().getName());
+        System.out.println("FCmp executed!");
+    }
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "i")
+    public void processI(NodeComponent bindCmp) {
+        DefaultContext context = bindCmp.getFirstContextBean();
+        context.setData("threadName", Thread.currentThread().getName());
+        System.out.println("ICmp executed!");
+    }
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_ITERATOR, nodeId = "it", nodeType = NodeTypeEnum.ITERATOR)
+    public Iterator<String> processIT(NodeComponent bindCmp) {
+        List<String> list = bindCmp.getRequestData();
+        return list.iterator();
+    }
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "w")
+    public void processW(NodeComponent bindCmp) {
+        DefaultContext context = bindCmp.getFirstContextBean();
+        context.setData("threadName", Thread.currentThread().getName());
+        System.out.println("WCmp executed!");
+    }
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_BOOLEAN, nodeId = "z", nodeType = NodeTypeEnum.BOOLEAN)
+    public boolean processZ(NodeComponent bindCmp) {
+        DefaultContext context = bindCmp.getFirstContextBean();
+        String key = "test";
+        if (context.hasData(key)) {
+            int count = context.getData("test");
+            return count < 5;
+        } else {
+            return true;
+        }
+    }
+
+}

+ 2 - 2
liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomThreadExecutor1.java

@@ -16,8 +16,8 @@ public class CustomThreadExecutor1 implements ExecutorBuilder {
 		if (ObjectUtil.isNull(liteflowConfig)) {
 		if (ObjectUtil.isNull(liteflowConfig)) {
 			liteflowConfig = new LiteflowConfig();
 			liteflowConfig = new LiteflowConfig();
 		}
 		}
-		return buildDefaultExecutor(liteflowConfig.getWhenMaxWorkers(), liteflowConfig.getWhenMaxWorkers(),
-				liteflowConfig.getWhenQueueLimit(), "customer-when-1-thead-");
+        return buildDefaultExecutor(liteflowConfig.getGlobalThreadPoolSize(), liteflowConfig.getGlobalThreadPoolSize(),
+                                    liteflowConfig.getGlobalThreadPoolQueueSize(), "customer-when-1-thead-");
 	}
 	}
 
 
 }
 }

+ 2 - 2
liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomThreadExecutor2.java

@@ -16,8 +16,8 @@ public class CustomThreadExecutor2 implements ExecutorBuilder {
 		if (ObjectUtil.isNull(liteflowConfig)) {
 		if (ObjectUtil.isNull(liteflowConfig)) {
 			liteflowConfig = new LiteflowConfig();
 			liteflowConfig = new LiteflowConfig();
 		}
 		}
-		return buildDefaultExecutor(liteflowConfig.getWhenMaxWorkers(), liteflowConfig.getWhenMaxWorkers(),
-				liteflowConfig.getWhenQueueLimit(), "customer-when-2-thead-");
+        return buildDefaultExecutor(liteflowConfig.getGlobalThreadPoolSize(), liteflowConfig.getGlobalThreadPoolSize(),
+                                    liteflowConfig.getGlobalThreadPoolQueueSize(), "customer-when-2-thead-");
 	}
 	}
 
 
 }
 }

+ 2 - 2
liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomThreadExecutor3.java

@@ -16,8 +16,8 @@ public class CustomThreadExecutor3 implements ExecutorBuilder {
 		if (ObjectUtil.isNull(liteflowConfig)) {
 		if (ObjectUtil.isNull(liteflowConfig)) {
 			liteflowConfig = new LiteflowConfig();
 			liteflowConfig = new LiteflowConfig();
 		}
 		}
-		return buildDefaultExecutor(liteflowConfig.getWhenMaxWorkers(), liteflowConfig.getWhenMaxWorkers(),
-				liteflowConfig.getWhenQueueLimit(), "customer-when-3-thead-");
+        return buildDefaultExecutor(liteflowConfig.getGlobalThreadPoolSize(), liteflowConfig.getGlobalThreadPoolSize(),
+                                    liteflowConfig.getGlobalThreadPoolQueueSize(), "customer-when-3-thead-");
 	}
 	}
 
 
 }
 }

+ 2 - 3
liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolELDeclMultiSpringbootTest.java

@@ -7,14 +7,13 @@ import com.yomahub.liteflow.test.BaseTest;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.junit.jupiter.api.extension.ExtendWith;
-import org.springframework.test.context.junit.jupiter.SpringExtension;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.test.context.TestPropertySource;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 
 
@@ -44,7 +43,7 @@ public class CustomWhenThreadPoolELDeclMultiSpringbootTest extends BaseTest {
 		LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg");
 		LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg");
 		DefaultContext context = response.getFirstContextBean();
 		DefaultContext context = response.getFirstContextBean();
 		Assertions.assertTrue(response.isSuccess());
 		Assertions.assertTrue(response.isSuccess());
-		Assertions.assertTrue(context.getData("threadName").toString().startsWith("when-thread-1"));
+		Assertions.assertTrue(context.getData("threadName").toString().startsWith("global-thread-1"));
 	}
 	}
 
 
 	/**
 	/**

+ 2 - 2
liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/java/com/yomahub/liteflow/test/parallelLoop/CustomThreadExecutor.java

@@ -16,8 +16,8 @@ public class CustomThreadExecutor implements ExecutorBuilder {
 		if (ObjectUtil.isNull(liteflowConfig)) {
 		if (ObjectUtil.isNull(liteflowConfig)) {
 			liteflowConfig = new LiteflowConfig();
 			liteflowConfig = new LiteflowConfig();
 		}
 		}
-		return buildDefaultExecutor(liteflowConfig.getParallelMaxWorkers(), liteflowConfig.getParallelMaxWorkers(),
-				liteflowConfig.getParallelQueueLimit(), "customer-loop-thead-");
+        return buildDefaultExecutor(liteflowConfig.getGlobalThreadPoolSize(), liteflowConfig.getGlobalThreadPoolSize(),
+                                    liteflowConfig.getGlobalThreadPoolQueueSize(), "customer-loop-thead-");
 	}
 	}
 
 
 }
 }

+ 1 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/chainThreadPool/application.properties

@@ -0,0 +1 @@
+liteflow.rule-source=chainThreadPool/flow.el.xml

+ 2 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/chainThreadPool/application2.properties

@@ -0,0 +1,2 @@
+liteflow.rule-source=chainThreadPool/flow2.el.xml
+liteflow.when-thread-pool-isolate=true

+ 4 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/chainThreadPool/application3.properties

@@ -0,0 +1,4 @@
+liteflow.rule-source=chainThreadPool/flow3.el.xml
+liteflow.global-thread-pool-size=16
+liteflow.global-thread-pool-queue-size=512
+liteflow.global-thread-pool-executor-class=com.yomahub.liteflow.test.chainThreadPool.CustomGlobalThreadExecutor

+ 22 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/chainThreadPool/flow.el.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<flow>
+    <chain name="chain1"
+           thread-pool-executor-class="com.yomahub.liteflow.test.chainThreadPool.CustomChainThreadExecutor">
+        WHEN(a,b);
+    </chain>
+
+    <chain name="chain2"
+           thread-pool-executor-class="com.yomahub.liteflow.test.chainThreadPool.CustomChainThreadExecutor">
+        FOR(5).parallel(true).DO(THEN(a,f));
+    </chain>
+
+    <chain name="chain3"
+           thread-pool-executor-class="com.yomahub.liteflow.test.chainThreadPool.CustomChainThreadExecutor">
+        WHILE(z).parallel(true).DO(THEN(w,d));
+    </chain>
+
+    <chain name="chain4"
+           thread-pool-executor-class="com.yomahub.liteflow.test.chainThreadPool.CustomChainThreadExecutor">
+        ITERATOR(it).parallel(true).DO(THEN(a,i));
+    </chain>
+</flow>

+ 22 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/chainThreadPool/flow2.el.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<flow>
+    <chain name="chain1"
+           thread-pool-executor-class="com.yomahub.liteflow.test.chainThreadPool.CustomChainThreadExecutor">
+        WHEN(a,b).threadPool("com.yomahub.liteflow.test.chainThreadPool.CustomWhenThreadExecutor");
+    </chain>
+
+    <chain name="chain2"
+           thread-pool-executor-class="com.yomahub.liteflow.test.chainThreadPool.CustomChainThreadExecutor">
+        FOR(5).parallel(true).DO(THEN(a,f)).threadPool("com.yomahub.liteflow.test.chainThreadPool.CustomLoopThreadExecutor");
+    </chain>
+
+    <chain name="chain3"
+           thread-pool-executor-class="com.yomahub.liteflow.test.chainThreadPool.CustomChainThreadExecutor">
+        WHILE(z).parallel(true).DO(THEN(w,d)).threadPool("com.yomahub.liteflow.test.chainThreadPool.CustomLoopThreadExecutor");
+    </chain>
+
+    <chain name="chain4"
+           thread-pool-executor-class="com.yomahub.liteflow.test.chainThreadPool.CustomChainThreadExecutor">
+        ITERATOR(it).parallel(true).DO(THEN(a,i)).threadPool("com.yomahub.liteflow.test.chainThreadPool.CustomLoopThreadExecutor");
+    </chain>
+</flow>

+ 19 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/chainThreadPool/flow3.el.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<flow>
+    <chain name="chain1">
+        WHEN(a,b);
+    </chain>
+
+    <chain name="chain2">
+        FOR(5).parallel(true).DO(THEN(a,f)
+        );
+    </chain>
+
+    <chain name="chain3">
+        WHILE(z).parallel(true).DO(THEN(w,d));
+    </chain>
+
+    <chain name="chain4">
+        ITERATOR(it).parallel(true).DO(THEN(a,i));
+    </chain>
+</flow>

+ 3 - 3
liteflow-testcase-el/liteflow-testcase-el-declare-multi-springboot/src/test/resources/parallelLoop/application.properties

@@ -1,4 +1,4 @@
 liteflow.rule-source=parallelLoop/flow.xml
 liteflow.rule-source=parallelLoop/flow.xml
-liteflow.parallel-max-workers = 10
-liteflow.parallel-queue-limit = 1024
-liteflow.parallel-loop-executor-class =com.yomahub.liteflow.test.parallelLoop.CustomThreadExecutor
+liteflow.global-thread-pool-size=16
+liteflow.global-thread-pool-queue-size=512
+liteflow.global-thread-pool-executor-class=com.yomahub.liteflow.test.parallelLoop.CustomThreadExecutor

+ 79 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/ChainThreadPoolELSpringbootTest.java

@@ -0,0 +1,79 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.collection.ListUtil;
+import com.yomahub.liteflow.core.FlowExecutor;
+import com.yomahub.liteflow.flow.LiteflowResponse;
+import com.yomahub.liteflow.slot.DefaultContext;
+import com.yomahub.liteflow.test.BaseTest;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.test.context.TestPropertySource;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * springboot环境下chain线程池隔离测试
+ */
+@TestPropertySource(value = "classpath:/chainThreadPool/application.properties")
+@SpringBootTest(classes = ChainThreadPoolELSpringbootTest.class)
+@EnableAutoConfiguration
+@ComponentScan({"com.yomahub.liteflow.test.chainThreadPool.cmp"})
+public class ChainThreadPoolELSpringbootTest extends BaseTest {
+
+    private final Logger log = LoggerFactory.getLogger(this.getClass());
+
+    @Resource
+    private FlowExecutor flowExecutor;
+
+    /**
+     * 测试WHEN上全局线程池和chain线程池隔离-优先以chain上为准
+     */
+    @Test
+    public void testChainThreadPool() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-chain-thead"));
+    }
+
+    /**
+     * 测试FOR上全局线程池和chain线程池隔离-优先以chain上为准
+     */
+    @Test
+    public void testChainThreadPool2() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain2", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-chain-thead"));
+    }
+
+    /**
+     * 测试WHILE上全局线程池和chain线程池隔离-优先以chain上为准
+     */
+    @Test
+    public void testChainThreadPool3() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain3", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-chain-thead"));
+    }
+
+    /**
+     * 测试ITERATOR上全局线程池和chain线程池隔离-优先以chain上为准
+     */
+    @Test
+    public void testChainThreadPool4() {
+        List<String> list = ListUtil.toList("1", "2", "3", "4", "5");
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain4", list);
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-chain-thead"));
+    }
+
+}

+ 79 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/ConditionThreadPoolELSpringbootTest.java

@@ -0,0 +1,79 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.collection.ListUtil;
+import com.yomahub.liteflow.core.FlowExecutor;
+import com.yomahub.liteflow.flow.LiteflowResponse;
+import com.yomahub.liteflow.slot.DefaultContext;
+import com.yomahub.liteflow.test.BaseTest;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.test.context.TestPropertySource;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * springboot环境下chain线程池隔离测试
+ */
+@TestPropertySource(value = "classpath:/chainThreadPool/application2.properties")
+@SpringBootTest(classes = ConditionThreadPoolELSpringbootTest.class)
+@EnableAutoConfiguration
+@ComponentScan({"com.yomahub.liteflow.test.chainThreadPool.cmp"})
+public class ConditionThreadPoolELSpringbootTest extends BaseTest {
+
+    private final Logger log = LoggerFactory.getLogger(this.getClass());
+
+    @Resource
+    private FlowExecutor flowExecutor;
+
+    /**
+     * 测试WEHN上condition线程池和chain线程池隔离-优先以WHEN上为准
+     */
+    @Test
+    public void testConditionThreadPool() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-when-thead"));
+    }
+
+    /**
+     * 测试FOR上condition线程池和chain线程池隔离-优先以FOR上为准
+     */
+    @Test
+    public void testConditionThreadPool2() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain2", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-loop-thead"));
+    }
+
+    /**
+     * 测试WHILE上condition线程池和chain线程池隔离-优先以WHILE上为准
+     */
+    @Test
+    public void testConditionThreadPool3() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain3", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-loop-thead"));
+    }
+
+    /**
+     * 测试ITERATOR上condition线程池和chain线程池隔离-优先以ITERATOR上为准
+     */
+    @Test
+    public void testConditionThreadPool4() {
+        List<String> list = ListUtil.toList("1", "2", "3", "4", "5");
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain4", list);
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-loop-thead"));
+    }
+
+}

+ 23 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomChainThreadExecutor.java

@@ -0,0 +1,23 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.yomahub.liteflow.property.LiteflowConfig;
+import com.yomahub.liteflow.property.LiteflowConfigGetter;
+import com.yomahub.liteflow.thread.ExecutorBuilder;
+
+import java.util.concurrent.ExecutorService;
+
+public class CustomChainThreadExecutor implements ExecutorBuilder {
+
+    @Override
+    public ExecutorService buildExecutor() {
+        LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
+        // 只有在非spring的场景下liteflowConfig才会为null
+        if (ObjectUtil.isNull(liteflowConfig)) {
+            liteflowConfig = new LiteflowConfig();
+        }
+        return buildDefaultExecutor(16, 16,
+                                    512, "customer-chain-thead");
+    }
+
+}

+ 23 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomGlobalThreadExecutor.java

@@ -0,0 +1,23 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.yomahub.liteflow.property.LiteflowConfig;
+import com.yomahub.liteflow.property.LiteflowConfigGetter;
+import com.yomahub.liteflow.thread.ExecutorBuilder;
+
+import java.util.concurrent.ExecutorService;
+
+public class CustomGlobalThreadExecutor implements ExecutorBuilder {
+
+    @Override
+    public ExecutorService buildExecutor() {
+        LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
+        // 只有在非spring的场景下liteflowConfig才会为null
+        if (ObjectUtil.isNull(liteflowConfig)) {
+            liteflowConfig = new LiteflowConfig();
+        }
+        return buildDefaultExecutor(16, 16,
+                                    512, "customer-global-thead");
+    }
+
+}

+ 23 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomLoopThreadExecutor.java

@@ -0,0 +1,23 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.yomahub.liteflow.property.LiteflowConfig;
+import com.yomahub.liteflow.property.LiteflowConfigGetter;
+import com.yomahub.liteflow.thread.ExecutorBuilder;
+
+import java.util.concurrent.ExecutorService;
+
+public class CustomLoopThreadExecutor implements ExecutorBuilder {
+
+    @Override
+    public ExecutorService buildExecutor() {
+        LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
+        // 只有在非spring的场景下liteflowConfig才会为null
+        if (ObjectUtil.isNull(liteflowConfig)) {
+            liteflowConfig = new LiteflowConfig();
+        }
+        return buildDefaultExecutor(16, 16,
+                                    512, "customer-loop-thead");
+    }
+
+}

+ 23 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomWhenThreadExecutor.java

@@ -0,0 +1,23 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.yomahub.liteflow.property.LiteflowConfig;
+import com.yomahub.liteflow.property.LiteflowConfigGetter;
+import com.yomahub.liteflow.thread.ExecutorBuilder;
+
+import java.util.concurrent.ExecutorService;
+
+public class CustomWhenThreadExecutor implements ExecutorBuilder {
+
+    @Override
+    public ExecutorService buildExecutor() {
+        LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
+        // 只有在非spring的场景下liteflowConfig才会为null
+        if (ObjectUtil.isNull(liteflowConfig)) {
+            liteflowConfig = new LiteflowConfig();
+        }
+        return buildDefaultExecutor(16, 16,
+                                    512, "customer-when-thead");
+    }
+
+}

+ 79 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/GlobalThreadPoolELSpringbootTest.java

@@ -0,0 +1,79 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.collection.ListUtil;
+import com.yomahub.liteflow.core.FlowExecutor;
+import com.yomahub.liteflow.flow.LiteflowResponse;
+import com.yomahub.liteflow.slot.DefaultContext;
+import com.yomahub.liteflow.test.BaseTest;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.test.context.TestPropertySource;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * springboot环境下Global线程池隔离测试
+ */
+@TestPropertySource(value = "classpath:/chainThreadPool/application3.properties")
+@SpringBootTest(classes = GlobalThreadPoolELSpringbootTest.class)
+@EnableAutoConfiguration
+@ComponentScan({"com.yomahub.liteflow.test.chainThreadPool.cmp"})
+public class GlobalThreadPoolELSpringbootTest extends BaseTest {
+
+    private final Logger log = LoggerFactory.getLogger(this.getClass());
+
+    @Resource
+    private FlowExecutor flowExecutor;
+
+    /**
+     * 测试WHEN上全局线程池
+     */
+    @Test
+    public void testGlobalThreadPool() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-global-thead"));
+    }
+
+    /**
+     * 测试FOR上全局线程池
+     */
+    @Test
+    public void testGlobalThreadPool2() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain2", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-global-thead"));
+    }
+
+    /**
+     * 测试WHILE上全局线程池
+     */
+    @Test
+    public void testGlobalThreadPool3() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain3", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-global-thead"));
+    }
+
+    /**
+     * 测试ITERATOR上全局线程池
+     */
+    @Test
+    public void testGlobalThreadPool4() {
+        List<String> list = ListUtil.toList("1", "2", "3", "4", "5");
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain4", list);
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-global-thead"));
+    }
+
+}

+ 24 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/ACmp.java

@@ -0,0 +1,24 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ *
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.chainThreadPool.cmp;
+
+import com.yomahub.liteflow.annotation.LiteflowMethod;
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
+import org.springframework.stereotype.Component;
+
+@Component("a")
+public class ACmp {
+
+    @LiteflowMethod(LiteFlowMethodEnum.PROCESS)
+    public void process(NodeComponent bindCmp) {
+        System.out.println("ACmp executed!");
+    }
+
+}

+ 27 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/BCmp.java

@@ -0,0 +1,27 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ *
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.chainThreadPool.cmp;
+
+import com.yomahub.liteflow.annotation.LiteflowMethod;
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
+import com.yomahub.liteflow.slot.DefaultContext;
+import org.springframework.stereotype.Component;
+
+@Component("b")
+public class BCmp {
+
+    @LiteflowMethod(LiteFlowMethodEnum.PROCESS)
+    public void process(NodeComponent bindCmp) {
+        DefaultContext context = bindCmp.getFirstContextBean();
+        context.setData("threadName", Thread.currentThread().getName());
+        System.out.println("BCmp executed!");
+    }
+
+}

+ 81 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/CmpConfig.java

@@ -0,0 +1,81 @@
+package com.yomahub.liteflow.test.chainThreadPool.cmp;
+
+import com.yomahub.liteflow.annotation.LiteflowComponent;
+import com.yomahub.liteflow.annotation.LiteflowMethod;
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
+import com.yomahub.liteflow.enums.NodeTypeEnum;
+import com.yomahub.liteflow.slot.DefaultContext;
+
+import java.util.Iterator;
+import java.util.List;
+
+@LiteflowComponent
+public class CmpConfig {
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "a")
+    public void processA(NodeComponent bindCmp) {
+
+        System.out.println("ACmp executed!");
+    }
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "b")
+    public void processB(NodeComponent bindCmp) {
+        DefaultContext context = bindCmp.getFirstContextBean();
+        context.setData("threadName", Thread.currentThread().getName());
+        System.out.println("BCmp executed!");
+    }
+
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "d")
+    public void processD(NodeComponent bindCmp) {
+        DefaultContext context = bindCmp.getFirstContextBean();
+        String key = "test";
+        if (context.hasData(key)) {
+            int count = context.getData(key);
+            context.setData(key, ++count);
+        } else {
+            context.setData(key, 1);
+        }
+    }
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "f")
+    public void processE(NodeComponent bindCmp) {
+        DefaultContext context = bindCmp.getFirstContextBean();
+        context.setData("threadName", Thread.currentThread().getName());
+        System.out.println("FCmp executed!");
+    }
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "i")
+    public void processI(NodeComponent bindCmp) {
+        DefaultContext context = bindCmp.getFirstContextBean();
+        context.setData("threadName", Thread.currentThread().getName());
+        System.out.println("ICmp executed!");
+    }
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_ITERATOR, nodeId = "it", nodeType = NodeTypeEnum.ITERATOR)
+    public Iterator<String> processIT(NodeComponent bindCmp) {
+        List<String> list = bindCmp.getRequestData();
+        return list.iterator();
+    }
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "w")
+    public void processW(NodeComponent bindCmp) {
+        DefaultContext context = bindCmp.getFirstContextBean();
+        context.setData("threadName", Thread.currentThread().getName());
+        System.out.println("WCmp executed!");
+    }
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_BOOLEAN, nodeId = "z", nodeType = NodeTypeEnum.BOOLEAN)
+    public boolean processZ(NodeComponent bindCmp) {
+        DefaultContext context = bindCmp.getFirstContextBean();
+        String key = "test";
+        if (context.hasData(key)) {
+            int count = context.getData("test");
+            return count < 5;
+        } else {
+            return true;
+        }
+    }
+
+}

+ 32 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/DCmp.java

@@ -0,0 +1,32 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ *
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.chainThreadPool.cmp;
+
+import com.yomahub.liteflow.annotation.LiteflowMethod;
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
+import com.yomahub.liteflow.slot.DefaultContext;
+import org.springframework.stereotype.Component;
+
+@Component("d")
+public class DCmp {
+
+    @LiteflowMethod(LiteFlowMethodEnum.PROCESS)
+    public void process(NodeComponent bindCmp) {
+        DefaultContext context = bindCmp.getFirstContextBean();
+        String key = "test";
+        if (context.hasData(key)) {
+            int count = context.getData(key);
+            context.setData(key, ++count);
+        } else {
+            context.setData(key, 1);
+        }
+    }
+
+}

+ 19 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/FCmp.java

@@ -0,0 +1,19 @@
+package com.yomahub.liteflow.test.chainThreadPool.cmp;
+
+import com.yomahub.liteflow.annotation.LiteflowMethod;
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
+import com.yomahub.liteflow.slot.DefaultContext;
+import org.springframework.stereotype.Component;
+
+@Component("f")
+public class FCmp {
+
+    @LiteflowMethod(LiteFlowMethodEnum.PROCESS)
+    public void process(NodeComponent bindCmp) {
+        DefaultContext context = bindCmp.getFirstContextBean();
+        context.setData("threadName", Thread.currentThread().getName());
+        System.out.println("FCmp executed!");
+    }
+
+}

+ 27 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/ICmp.java

@@ -0,0 +1,27 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ *
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.chainThreadPool.cmp;
+
+import com.yomahub.liteflow.annotation.LiteflowMethod;
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
+import com.yomahub.liteflow.slot.DefaultContext;
+import org.springframework.stereotype.Component;
+
+@Component("i")
+public class ICmp {
+
+    @LiteflowMethod(LiteFlowMethodEnum.PROCESS)
+    public void process(NodeComponent bindCmp) {
+        DefaultContext context = bindCmp.getFirstContextBean();
+        context.setData("threadName", Thread.currentThread().getName());
+        System.out.println("ICmp executed!");
+    }
+
+}

+ 23 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/ITCmp.java

@@ -0,0 +1,23 @@
+package com.yomahub.liteflow.test.chainThreadPool.cmp;
+
+import com.yomahub.liteflow.annotation.LiteflowCmpDefine;
+import com.yomahub.liteflow.annotation.LiteflowMethod;
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
+import com.yomahub.liteflow.enums.NodeTypeEnum;
+import org.springframework.stereotype.Component;
+
+import java.util.Iterator;
+import java.util.List;
+
+@Component("it")
+@LiteflowCmpDefine(NodeTypeEnum.ITERATOR)
+public class ITCmp {
+
+    @LiteflowMethod(LiteFlowMethodEnum.PROCESS_ITERATOR)
+    public Iterator<?> processIterator(NodeComponent bindCmp) throws Exception {
+        List<String> list = bindCmp.getRequestData();
+        return list.iterator();
+    }
+
+}

+ 27 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/WCmp.java

@@ -0,0 +1,27 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ *
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.chainThreadPool.cmp;
+
+import com.yomahub.liteflow.annotation.LiteflowMethod;
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
+import com.yomahub.liteflow.slot.DefaultContext;
+import org.springframework.stereotype.Component;
+
+@Component("w")
+public class WCmp {
+
+    @LiteflowMethod(LiteFlowMethodEnum.PROCESS)
+    public void process(NodeComponent bindCmp) {
+        DefaultContext context = bindCmp.getFirstContextBean();
+        context.setData("threadName", Thread.currentThread().getName());
+        System.out.println("WCmp executed!");
+    }
+
+}

+ 25 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/ZCmp.java

@@ -0,0 +1,25 @@
+package com.yomahub.liteflow.test.chainThreadPool.cmp;
+
+import com.yomahub.liteflow.annotation.LiteflowComponent;
+import com.yomahub.liteflow.annotation.LiteflowMethod;
+import com.yomahub.liteflow.core.NodeComponent;
+import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
+import com.yomahub.liteflow.enums.NodeTypeEnum;
+import com.yomahub.liteflow.slot.DefaultContext;
+
+@LiteflowComponent("z")
+public class ZCmp {
+
+    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_BOOLEAN, nodeType = NodeTypeEnum.BOOLEAN)
+    public boolean processWhile(NodeComponent bindCmp) throws Exception {
+        DefaultContext context = bindCmp.getFirstContextBean();
+        String key = "test";
+        if (context.hasData(key)) {
+            int count = context.getData("test");
+            return count < 5;
+        } else {
+            return true;
+        }
+    }
+
+}

+ 2 - 2
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomThreadExecutor1.java

@@ -16,8 +16,8 @@ public class CustomThreadExecutor1 implements ExecutorBuilder {
 		if (ObjectUtil.isNull(liteflowConfig)) {
 		if (ObjectUtil.isNull(liteflowConfig)) {
 			liteflowConfig = new LiteflowConfig();
 			liteflowConfig = new LiteflowConfig();
 		}
 		}
-		return buildDefaultExecutor(liteflowConfig.getWhenMaxWorkers(), liteflowConfig.getWhenMaxWorkers(),
-				liteflowConfig.getWhenQueueLimit(), "customer-when-1-thead-");
+        return buildDefaultExecutor(liteflowConfig.getGlobalThreadPoolSize(), liteflowConfig.getGlobalThreadPoolSize(),
+                                    liteflowConfig.getGlobalThreadPoolSize(), "customer-when-1-thead-");
 	}
 	}
 
 
 }
 }

+ 2 - 2
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomThreadExecutor2.java

@@ -16,8 +16,8 @@ public class CustomThreadExecutor2 implements ExecutorBuilder {
 		if (ObjectUtil.isNull(liteflowConfig)) {
 		if (ObjectUtil.isNull(liteflowConfig)) {
 			liteflowConfig = new LiteflowConfig();
 			liteflowConfig = new LiteflowConfig();
 		}
 		}
-		return buildDefaultExecutor(liteflowConfig.getWhenMaxWorkers(), liteflowConfig.getWhenMaxWorkers(),
-				liteflowConfig.getWhenQueueLimit(), "customer-when-2-thead-");
+        return buildDefaultExecutor(liteflowConfig.getGlobalThreadPoolSize(), liteflowConfig.getGlobalThreadPoolSize(),
+                                    liteflowConfig.getGlobalThreadPoolQueueSize(), "customer-when-2-thead-");
 	}
 	}
 
 
 }
 }

+ 2 - 2
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomThreadExecutor3.java

@@ -16,8 +16,8 @@ public class CustomThreadExecutor3 implements ExecutorBuilder {
 		if (ObjectUtil.isNull(liteflowConfig)) {
 		if (ObjectUtil.isNull(liteflowConfig)) {
 			liteflowConfig = new LiteflowConfig();
 			liteflowConfig = new LiteflowConfig();
 		}
 		}
-		return buildDefaultExecutor(liteflowConfig.getWhenMaxWorkers(), liteflowConfig.getWhenMaxWorkers(),
-				liteflowConfig.getWhenQueueLimit(), "customer-when-3-thead-");
+        return buildDefaultExecutor(liteflowConfig.getGlobalThreadPoolSize(), liteflowConfig.getGlobalThreadPoolSize(),
+                                    liteflowConfig.getGlobalThreadPoolQueueSize(), "customer-when-3-thead-");
 	}
 	}
 
 
 }
 }

+ 2 - 3
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/customWhenThreadPool/CustomWhenThreadPoolELDeclSpringbootTest.java

@@ -7,14 +7,13 @@ import com.yomahub.liteflow.test.BaseTest;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.junit.jupiter.api.extension.ExtendWith;
-import org.springframework.test.context.junit.jupiter.SpringExtension;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.test.context.TestPropertySource;
 import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 
 
@@ -44,7 +43,7 @@ public class CustomWhenThreadPoolELDeclSpringbootTest extends BaseTest {
 		LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg");
 		LiteflowResponse response = flowExecutor.execute2Resp("chain", "arg");
 		DefaultContext context = response.getFirstContextBean();
 		DefaultContext context = response.getFirstContextBean();
 		Assertions.assertTrue(response.isSuccess());
 		Assertions.assertTrue(response.isSuccess());
-		Assertions.assertTrue(context.getData("threadName").toString().startsWith("when-thread-1"));
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("global-thread-1"));
 	}
 	}
 
 
 	/**
 	/**

+ 2 - 2
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/java/com/yomahub/liteflow/test/parallelLoop/CustomThreadExecutor.java

@@ -16,8 +16,8 @@ public class CustomThreadExecutor implements ExecutorBuilder {
 		if (ObjectUtil.isNull(liteflowConfig)) {
 		if (ObjectUtil.isNull(liteflowConfig)) {
 			liteflowConfig = new LiteflowConfig();
 			liteflowConfig = new LiteflowConfig();
 		}
 		}
-		return buildDefaultExecutor(liteflowConfig.getParallelMaxWorkers(), liteflowConfig.getParallelMaxWorkers(),
-				liteflowConfig.getParallelQueueLimit(), "customer-loop-thead-");
+        return buildDefaultExecutor(liteflowConfig.getGlobalThreadPoolSize(), liteflowConfig.getGlobalThreadPoolSize(),
+                                    liteflowConfig.getGlobalThreadPoolQueueSize(), "customer-loop-thead-");
 	}
 	}
 
 
 }
 }

+ 1 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/chainThreadPool/application.properties

@@ -0,0 +1 @@
+liteflow.rule-source=chainThreadPool/flow.el.xml

+ 2 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/chainThreadPool/application2.properties

@@ -0,0 +1,2 @@
+liteflow.rule-source=chainThreadPool/flow2.el.xml
+liteflow.when-thread-pool-isolate=true

+ 4 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/chainThreadPool/application3.properties

@@ -0,0 +1,4 @@
+liteflow.rule-source=chainThreadPool/flow3.el.xml
+liteflow.global-thread-pool-size=16
+liteflow.global-thread-pool-queue-size=512
+liteflow.global-thread-pool-executor-class=com.yomahub.liteflow.test.chainThreadPool.CustomGlobalThreadExecutor

+ 22 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/chainThreadPool/flow.el.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<flow>
+    <chain name="chain1"
+           thread-pool-executor-class="com.yomahub.liteflow.test.chainThreadPool.CustomChainThreadExecutor">
+        WHEN(a,b);
+    </chain>
+
+    <chain name="chain2"
+           thread-pool-executor-class="com.yomahub.liteflow.test.chainThreadPool.CustomChainThreadExecutor">
+        FOR(5).parallel(true).DO(THEN(a,f));
+    </chain>
+
+    <chain name="chain3"
+           thread-pool-executor-class="com.yomahub.liteflow.test.chainThreadPool.CustomChainThreadExecutor">
+        WHILE(z).parallel(true).DO(THEN(w,d));
+    </chain>
+
+    <chain name="chain4"
+           thread-pool-executor-class="com.yomahub.liteflow.test.chainThreadPool.CustomChainThreadExecutor">
+        ITERATOR(it).parallel(true).DO(THEN(a,i));
+    </chain>
+</flow>

+ 22 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/chainThreadPool/flow2.el.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<flow>
+    <chain name="chain1"
+           thread-pool-executor-class="com.yomahub.liteflow.test.chainThreadPool.CustomChainThreadExecutor">
+        WHEN(a,b).threadPool("com.yomahub.liteflow.test.chainThreadPool.CustomWhenThreadExecutor");
+    </chain>
+
+    <chain name="chain2"
+           thread-pool-executor-class="com.yomahub.liteflow.test.chainThreadPool.CustomChainThreadExecutor">
+        FOR(5).parallel(true).DO(THEN(a,f)).threadPool("com.yomahub.liteflow.test.chainThreadPool.CustomLoopThreadExecutor");
+    </chain>
+
+    <chain name="chain3"
+           thread-pool-executor-class="com.yomahub.liteflow.test.chainThreadPool.CustomChainThreadExecutor">
+        WHILE(z).parallel(true).DO(THEN(w,d)).threadPool("com.yomahub.liteflow.test.chainThreadPool.CustomLoopThreadExecutor");
+    </chain>
+
+    <chain name="chain4"
+           thread-pool-executor-class="com.yomahub.liteflow.test.chainThreadPool.CustomChainThreadExecutor">
+        ITERATOR(it).parallel(true).DO(THEN(a,i)).threadPool("com.yomahub.liteflow.test.chainThreadPool.CustomLoopThreadExecutor");
+    </chain>
+</flow>

+ 19 - 0
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/chainThreadPool/flow3.el.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<flow>
+    <chain name="chain1">
+        WHEN(a,b);
+    </chain>
+
+    <chain name="chain2">
+        FOR(5).parallel(true).DO(THEN(a,f)
+        );
+    </chain>
+
+    <chain name="chain3">
+        WHILE(z).parallel(true).DO(THEN(w,d));
+    </chain>
+
+    <chain name="chain4">
+        ITERATOR(it).parallel(true).DO(THEN(a,i));
+    </chain>
+</flow>

+ 3 - 3
liteflow-testcase-el/liteflow-testcase-el-declare-springboot/src/test/resources/parallelLoop/application.properties

@@ -1,4 +1,4 @@
 liteflow.rule-source=parallelLoop/flow.xml
 liteflow.rule-source=parallelLoop/flow.xml
-liteflow.parallel-max-workers = 10
-liteflow.parallel-queue-limit = 1024
-liteflow.parallel-loop-executor-class =com.yomahub.liteflow.test.parallelLoop.CustomThreadExecutor
+liteflow.global-thread-pool-size=16
+liteflow.global-thread-pool-queue-size=512
+liteflow.global-thread-pool-executor-class=com.yomahub.liteflow.test.parallelLoop.CustomThreadExecutor

+ 76 - 0
liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/chainThreadPool/ChainThreadPoolELSpringbootTest.java

@@ -0,0 +1,76 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.collection.ListUtil;
+import com.yomahub.liteflow.core.FlowExecutor;
+import com.yomahub.liteflow.core.FlowExecutorHolder;
+import com.yomahub.liteflow.flow.LiteflowResponse;
+import com.yomahub.liteflow.property.LiteflowConfig;
+import com.yomahub.liteflow.slot.DefaultContext;
+import com.yomahub.liteflow.test.BaseTest;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+
+/**
+ * springboot环境下chain线程池隔离测试
+ */
+
+public class ChainThreadPoolELSpringbootTest extends BaseTest {
+
+    private static FlowExecutor flowExecutor;
+
+    @BeforeAll
+    public static void init() {
+        LiteflowConfig config = new LiteflowConfig();
+        config.setRuleSource("chainThreadPool/flow.el.xml");
+        flowExecutor = FlowExecutorHolder.loadInstance(config);
+    }
+
+    /**
+     * 测试WHEN上全局线程池和chain线程池隔离-优先以chain上为准
+     */
+    @Test
+    public void testChainThreadPool() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-chain-thead"));
+    }
+
+    /**
+     * 测试FOR上全局线程池和chain线程池隔离-优先以chain上为准
+     */
+    @Test
+    public void testChainThreadPool2() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain2", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-chain-thead"));
+    }
+
+    /**
+     * 测试WHILE上全局线程池和chain线程池隔离-优先以chain上为准
+     */
+    @Test
+    public void testChainThreadPool3() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain3", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-chain-thead"));
+    }
+
+    /**
+     * 测试ITERATOR上全局线程池和chain线程池隔离-优先以chain上为准
+     */
+    @Test
+    public void testChainThreadPool4() {
+        List<String> list = ListUtil.toList("1", "2", "3", "4", "5");
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain4", list);
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-chain-thead"));
+    }
+
+}

+ 76 - 0
liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/chainThreadPool/ConditionThreadPoolELSpringbootTest.java

@@ -0,0 +1,76 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.collection.ListUtil;
+import com.yomahub.liteflow.core.FlowExecutor;
+import com.yomahub.liteflow.core.FlowExecutorHolder;
+import com.yomahub.liteflow.flow.LiteflowResponse;
+import com.yomahub.liteflow.property.LiteflowConfig;
+import com.yomahub.liteflow.slot.DefaultContext;
+import com.yomahub.liteflow.test.BaseTest;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+
+/**
+ * springboot环境下chain线程池隔离测试
+ */
+public class ConditionThreadPoolELSpringbootTest extends BaseTest {
+
+    private static FlowExecutor flowExecutor;
+
+    @BeforeAll
+    public static void init() {
+        LiteflowConfig config = new LiteflowConfig();
+        config.setRuleSource("chainThreadPool/flow2.el.xml");
+        config.setWhenThreadPoolIsolate(true);
+        flowExecutor = FlowExecutorHolder.loadInstance(config);
+    }
+
+    /**
+     * 测试WEHN上condition线程池和chain线程池隔离-优先以WHEN上为准
+     */
+    @Test
+    public void testConditionThreadPool() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-when-thead"));
+    }
+
+    /**
+     * 测试FOR上condition线程池和chain线程池隔离-优先以FOR上为准
+     */
+    @Test
+    public void testConditionThreadPool2() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain2", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-loop-thead"));
+    }
+
+    /**
+     * 测试WHILE上condition线程池和chain线程池隔离-优先以WHILE上为准
+     */
+    @Test
+    public void testConditionThreadPool3() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain3", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-loop-thead"));
+    }
+
+    /**
+     * 测试ITERATOR上condition线程池和chain线程池隔离-优先以ITERATOR上为准
+     */
+    @Test
+    public void testConditionThreadPool4() {
+        List<String> list = ListUtil.toList("1", "2", "3", "4", "5");
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain4", list);
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-loop-thead"));
+    }
+
+}

+ 23 - 0
liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomChainThreadExecutor.java

@@ -0,0 +1,23 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.yomahub.liteflow.property.LiteflowConfig;
+import com.yomahub.liteflow.property.LiteflowConfigGetter;
+import com.yomahub.liteflow.thread.ExecutorBuilder;
+
+import java.util.concurrent.ExecutorService;
+
+public class CustomChainThreadExecutor implements ExecutorBuilder {
+
+    @Override
+    public ExecutorService buildExecutor() {
+        LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
+        // 只有在非spring的场景下liteflowConfig才会为null
+        if (ObjectUtil.isNull(liteflowConfig)) {
+            liteflowConfig = new LiteflowConfig();
+        }
+        return buildDefaultExecutor(16, 16,
+                                    512, "customer-chain-thead");
+    }
+
+}

+ 23 - 0
liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomGlobalThreadExecutor.java

@@ -0,0 +1,23 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.yomahub.liteflow.property.LiteflowConfig;
+import com.yomahub.liteflow.property.LiteflowConfigGetter;
+import com.yomahub.liteflow.thread.ExecutorBuilder;
+
+import java.util.concurrent.ExecutorService;
+
+public class CustomGlobalThreadExecutor implements ExecutorBuilder {
+
+    @Override
+    public ExecutorService buildExecutor() {
+        LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
+        // 只有在非spring的场景下liteflowConfig才会为null
+        if (ObjectUtil.isNull(liteflowConfig)) {
+            liteflowConfig = new LiteflowConfig();
+        }
+        return buildDefaultExecutor(16, 16,
+                                    512, "customer-global-thead");
+    }
+
+}

+ 23 - 0
liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomLoopThreadExecutor.java

@@ -0,0 +1,23 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.yomahub.liteflow.property.LiteflowConfig;
+import com.yomahub.liteflow.property.LiteflowConfigGetter;
+import com.yomahub.liteflow.thread.ExecutorBuilder;
+
+import java.util.concurrent.ExecutorService;
+
+public class CustomLoopThreadExecutor implements ExecutorBuilder {
+
+    @Override
+    public ExecutorService buildExecutor() {
+        LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
+        // 只有在非spring的场景下liteflowConfig才会为null
+        if (ObjectUtil.isNull(liteflowConfig)) {
+            liteflowConfig = new LiteflowConfig();
+        }
+        return buildDefaultExecutor(16, 16,
+                                    512, "customer-loop-thead");
+    }
+
+}

+ 23 - 0
liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/chainThreadPool/CustomWhenThreadExecutor.java

@@ -0,0 +1,23 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.util.ObjectUtil;
+import com.yomahub.liteflow.property.LiteflowConfig;
+import com.yomahub.liteflow.property.LiteflowConfigGetter;
+import com.yomahub.liteflow.thread.ExecutorBuilder;
+
+import java.util.concurrent.ExecutorService;
+
+public class CustomWhenThreadExecutor implements ExecutorBuilder {
+
+    @Override
+    public ExecutorService buildExecutor() {
+        LiteflowConfig liteflowConfig = LiteflowConfigGetter.get();
+        // 只有在非spring的场景下liteflowConfig才会为null
+        if (ObjectUtil.isNull(liteflowConfig)) {
+            liteflowConfig = new LiteflowConfig();
+        }
+        return buildDefaultExecutor(16, 16,
+                                    512, "customer-when-thead");
+    }
+
+}

+ 80 - 0
liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/chainThreadPool/GlobalThreadPoolELSpringbootTest.java

@@ -0,0 +1,80 @@
+package com.yomahub.liteflow.test.chainThreadPool;
+
+import cn.hutool.core.collection.ListUtil;
+import com.yomahub.liteflow.core.FlowExecutor;
+import com.yomahub.liteflow.core.FlowExecutorHolder;
+import com.yomahub.liteflow.flow.LiteflowResponse;
+import com.yomahub.liteflow.property.LiteflowConfig;
+import com.yomahub.liteflow.slot.DefaultContext;
+import com.yomahub.liteflow.test.BaseTest;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+
+/**
+ * springboot环境下Global线程池隔离测试
+ */
+
+public class GlobalThreadPoolELSpringbootTest extends BaseTest {
+
+
+    private static FlowExecutor flowExecutor;
+
+    @BeforeAll
+    public static void init() {
+        LiteflowConfig config = new LiteflowConfig();
+        config.setRuleSource("chainThreadPool/flow3.el.xml");
+        config.setGlobalThreadPoolSize(10);
+        config.setGlobalThreadPoolQueueSize(1024);
+        config.setGlobalThreadPoolExecutorClass("com.yomahub.liteflow.test.chainThreadPool.CustomGlobalThreadExecutor");
+        flowExecutor = FlowExecutorHolder.loadInstance(config);
+    }
+
+    /**
+     * 测试WHEN上全局线程池
+     */
+    @Test
+    public void testGlobalThreadPool() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain1", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-global-thead"));
+    }
+
+    /**
+     * 测试FOR上全局线程池
+     */
+    @Test
+    public void testGlobalThreadPool2() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain2", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-global-thead"));
+    }
+
+    /**
+     * 测试WHILE上全局线程池
+     */
+    @Test
+    public void testGlobalThreadPool3() {
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain3", "arg");
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-global-thead"));
+    }
+
+    /**
+     * 测试ITERATOR上全局线程池
+     */
+    @Test
+    public void testGlobalThreadPool4() {
+        List<String> list = ListUtil.toList("1", "2", "3", "4", "5");
+        LiteflowResponse response1 = flowExecutor.execute2Resp("chain4", list);
+        DefaultContext context = response1.getFirstContextBean();
+        Assertions.assertTrue(response1.isSuccess());
+        Assertions.assertTrue(context.getData("threadName").toString().startsWith("customer-global-thead"));
+    }
+
+}

+ 21 - 0
liteflow-testcase-el/liteflow-testcase-el-nospring/src/test/java/com/yomahub/liteflow/test/chainThreadPool/cmp/ACmp.java

@@ -0,0 +1,21 @@
+/**
+ * <p>Title: liteflow</p>
+ * <p>Description: 轻量级的组件式流程框架</p>
+ *
+ * @author Bryan.Zhang
+ * @email weenyc31@163.com
+ * @Date 2020/4/1
+ */
+package com.yomahub.liteflow.test.chainThreadPool.cmp;
+
+import com.yomahub.liteflow.core.NodeComponent;
+
+
+public class ACmp extends NodeComponent {
+
+    @Override
+    public void process() {
+        System.out.println("ACmp executed!");
+    }
+
+}

Some files were not shown because too many files changed in this diff