mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 20:22:07 +08:00
feature enhancement #I49FDK 中断重试目前是全局的,希望增加针对个别组件和特定exception
This commit is contained in:
@@ -33,9 +33,29 @@ public class LiteflowRetrySpringbootTest extends BaseTest {
|
||||
private FlowExecutor flowExecutor;
|
||||
|
||||
@Test
|
||||
public void testRetry() {
|
||||
public void testRetry1() {
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain1", "arg");
|
||||
Assert.assertTrue(response.isSuccess());
|
||||
Assert.assertEquals("a==>b==>b==>b==>c==>a==>d", response.getSlot().printStep());
|
||||
Assert.assertEquals("a==>b==>b==>b", response.getSlot().printStep());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetry2() {
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain2", "arg");
|
||||
Assert.assertFalse(response.isSuccess());
|
||||
Assert.assertEquals("c==>c==>c==>c==>c==>c", response.getSlot().printStep());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetry3() {
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain3", "arg");
|
||||
Assert.assertFalse(response.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRetry4() {
|
||||
LiteflowResponse<DefaultSlot> response = flowExecutor.execute2Resp("chain4", "arg");
|
||||
Assert.assertFalse(response.isSuccess());
|
||||
Assert.assertEquals("e==>e==>e==>e==>e==>e", response.getSlot().printStep());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,14 +8,18 @@
|
||||
package com.yomahub.liteflow.test.cmpRetry.cmp;
|
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||
import com.yomahub.liteflow.annotation.LiteflowRetry;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
|
||||
@LiteflowComponent("c")
|
||||
@LiteflowRetry(5)
|
||||
public class CCmp extends NodeComponent {
|
||||
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("CCmp executed!");
|
||||
throw new RuntimeException("demo exception");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,14 +8,17 @@
|
||||
package com.yomahub.liteflow.test.cmpRetry.cmp;
|
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||
import com.yomahub.liteflow.annotation.LiteflowRetry;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
|
||||
@LiteflowComponent("d")
|
||||
@LiteflowRetry(retry = 5, forExceptions = {NullPointerException.class})
|
||||
public class DCmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("DCmp executed!");
|
||||
throw new RuntimeException("demo exception");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.cmpRetry.cmp;
|
||||
|
||||
import com.yomahub.liteflow.annotation.LiteflowComponent;
|
||||
import com.yomahub.liteflow.annotation.LiteflowRetry;
|
||||
import com.yomahub.liteflow.core.NodeComponent;
|
||||
|
||||
@LiteflowComponent("e")
|
||||
@LiteflowRetry(retry = 5, forExceptions = {NullPointerException.class})
|
||||
public class ECmp extends NodeComponent {
|
||||
|
||||
@Override
|
||||
public void process() {
|
||||
System.out.println("ECmp executed!");
|
||||
throw new NullPointerException("demo null exception");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow>
|
||||
<chain name="chain1">
|
||||
<then value="a,b,chain2"/>
|
||||
<then value="a,b"/>
|
||||
</chain>
|
||||
|
||||
<chain name="chain2">
|
||||
<then value="c,a,d"/>
|
||||
<then value="c"/>
|
||||
</chain>
|
||||
|
||||
<chain name="chain3">
|
||||
<then value="d"/>
|
||||
</chain>
|
||||
|
||||
<chain name="chain4">
|
||||
<then value="e"/>
|
||||
</chain>
|
||||
</flow>
|
||||
Reference in New Issue
Block a user