optimize liteflow example

This commit is contained in:
yanhom 2024-09-11 23:50:59 +08:00
parent 484be56a99
commit 515793bea9
6 changed files with 39 additions and 6 deletions

View File

@ -18,6 +18,8 @@
package org.dromara.dynamictp.example.cmp;
import com.yomahub.liteflow.core.NodeComponent;
import lombok.extern.slf4j.Slf4j;
import org.dromara.dynamictp.example.ctx.CusCtx;
import org.springframework.stereotype.Component;
/**
@ -26,12 +28,14 @@ import org.springframework.stereotype.Component;
* @author yanhom
* @since 1.1.9
*/
@Slf4j
@Component("a")
public class ACmp extends NodeComponent {
@Override
public void process() {
//do your business
CusCtx ctx = this.getFirstContextBean();
log.info("a, ctx:{}", ctx);
}
}

View File

@ -18,6 +18,8 @@
package org.dromara.dynamictp.example.cmp;
import com.yomahub.liteflow.core.NodeComponent;
import lombok.extern.slf4j.Slf4j;
import org.dromara.dynamictp.example.ctx.CusCtx;
import org.springframework.stereotype.Component;
/**
@ -26,12 +28,14 @@ import org.springframework.stereotype.Component;
* @author yanhom
* @since 1.1.9
*/
@Slf4j
@Component("b")
public class BCmp extends NodeComponent {
@Override
public void process() {
//do your business
CusCtx ctx = this.getFirstContextBean();
log.info("b, ctx:{}", ctx);
}
}

View File

@ -18,6 +18,8 @@
package org.dromara.dynamictp.example.cmp;
import com.yomahub.liteflow.core.NodeComponent;
import lombok.extern.slf4j.Slf4j;
import org.dromara.dynamictp.example.ctx.CusCtx;
import org.springframework.stereotype.Component;
/**
@ -26,12 +28,14 @@ import org.springframework.stereotype.Component;
* @author yanhom
* @since 1.1.9
*/
@Slf4j
@Component("c")
public class CCmp extends NodeComponent {
@Override
public void process() {
//do your business
CusCtx ctx = this.getFirstContextBean();
log.info("c, ctx:{}", ctx);
}
}

View File

@ -0,0 +1,19 @@
package org.dromara.dynamictp.example.ctx;
import lombok.AllArgsConstructor;
import lombok.Data;
/**
* CusCtx related
*
* @author yanhom
* @since 1.1.0
*/
@AllArgsConstructor(staticName = "of")
@Data
public class CusCtx {
private Long id;
private String name;
}

View File

@ -20,6 +20,7 @@ package org.dromara.dynamictp.example.service;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.flow.LiteflowResponse;
import lombok.extern.slf4j.Slf4j;
import org.dromara.dynamictp.example.ctx.CusCtx;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -37,8 +38,9 @@ public class BizService {
@Resource
private FlowExecutor flowExecutor;
public void testConfig(){
LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
public void testConfig() {
CusCtx ctx = CusCtx.of(1L, "test");
LiteflowResponse response = flowExecutor.execute2Resp("chain1", null, ctx);
log.info("response:{}", response);
}
}

View File

@ -16,7 +16,7 @@ spring:
enabledCollect: true # 是否开启监控指标采集默认false
collectorTypes: logging # 监控数据采集器类型logging | micrometer | internal_logging默认micrometer
monitorInterval: 5
liteflowTp: # 通知报警平台配置
liteflowTp:
- threadPoolName: liteflowTp#LiteFlowDefaultWhenExecutorBuilder
corePoolSize: 10
maximumPoolSize: 20