enhancement #I4FSHW 优雅刷新配置的支持

This commit is contained in:
bryan31
2021-11-11 00:50:19 +08:00
parent 30b28729e0
commit 8be6d00c82
12 changed files with 263 additions and 61 deletions

View File

@@ -1,5 +1,6 @@
package com.yomahub.liteflow.test;
import com.yomahub.liteflow.entity.data.DataBus;
import com.yomahub.liteflow.flow.FlowBus;
import com.yomahub.liteflow.spring.ComponentScanner;
import org.junit.AfterClass;

View File

@@ -33,11 +33,38 @@ public class RefreshRuleSpringbootTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
//测试普通刷新流程的场景
@Test
public void testRefresh() throws Exception{
String content = ResourceUtil.readUtf8Str("classpath: /refreshRule/flow.xml");
public void testRefresh1() throws Exception{
String content = ResourceUtil.readUtf8Str("classpath: /refreshRule/flow_update.xml");
FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_XML, content);
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
}
//测试优雅刷新的场景
@Test
public void testRefresh2() throws Exception{
new Thread(() -> {
try {
Thread.sleep(1000L);
String content = ResourceUtil.readUtf8Str("classpath: /refreshRule/flow_update.xml");
FlowBus.refreshFlowMetaData(FlowParserTypeEnum.TYPE_XML, content);
} catch (Exception e) {
e.printStackTrace();
}
}).start();
for (int i = 0; i < 500; i++) {
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg");
Assert.assertTrue(response.isSuccess());
try {
Thread.sleep(10L);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}

View File

@@ -1,2 +1 @@
liteflow.rule-source=refreshRule/flow.xml
liteflow.parse-on-start=false
liteflow.rule-source=refreshRule/flow.xml

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<chain name="chain1">
<then value="c,b,a"/>
</chain>
</flow>