hero

流程编排、规则判断、并发、微服务整合框架

使用场景→

业务可视

编排好的图示模型即为代码真实的执行链路,以所见即所得的方式在技术和业务之间架起一道通用语言的桥梁

动态配置

主流程、子流程、角色、变量等支持动态化配置,支持包括开源和公司自研在内的全部存储介质

业务抽象

引入资源、权限、角色等概念,构建定制化业务身份,为抽象化业务能力提供技术支持和解决方案

# 相关文档

# 接入成本极低

# 1、配置引入

<dependency>
    <groupId>cn.kstry.framework</groupId>
    <artifactId>kstry-core</artifactId>
    <version>1.1.16</version>
</dependency>
1
2
3
4
5

查看最新版本 (opens new window)

# 2、项目引入

@SpringBootApplication
@EnableKstry(bpmnPath = "./bpmn/*.bpmn")
public class KstryDemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(KstryDemoApplication.class, args);
    }
}
1
2
3
4
5
6
7
8

# 3、编写组件代码

@TaskComponent
public class CalculateService {

    @TaskService
    public ScopeDataNotice setNumber() {
        return ScopeDataNotice.var().notice("b", 10);
    }

    @NoticeResult
    @TaskService
    public int plusCalculate(@VarTaskParam int a, @VarTaskParam int b) {
        return a + b;
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14

# 4、流程配置

# 方式一:BPMN配置文件定义流程

TIP

BPMN文件(流程图文件)流程配置地址:Kstry流程配置台 (opens new window)

46d5742905b889a15333b4089ce7cfdf

# 方式二:代码定义流程

@Configuration
public class ProcessConfig {

    @Bean
    public ProcessLink testSimpleFlowDemoProcess() {
        StartProcessLink processLink = StartProcessLink.build(ProcessConfig::testSimpleFlowDemoProcess);
        processLink
                .nextService(CalculateService::setNumber).build()
                .nextService(CalculateService::plusCalculate).build()
                .end();
        return processLink;
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13

# 5、调用执行

@Test
public void testSimpleFlowDemo() {
    RuleJudgeRequest ruleJudgeRequest = new RuleJudgeRequest();
    ruleJudgeRequest.setA(5);

    // 流程配置执行
    StoryRequest<Integer> fireRequest = ReqBuilder.returnType(Integer.class)
            .trackingType(TrackingTypeEnum.SERVICE_DETAIL).varScopeData(ruleJudgeRequest).startId("test-simple-flow-demo")
            .build();
    TaskResponse<Integer> result = storyEngine.fire(fireRequest);
    Assert.assertTrue(result.isSuccess());
    Assert.assertEquals(15, (int) result.getResult());

    // 代码定义执行
    fireRequest = ReqBuilder.returnType(Integer.class)
            .trackingType(TrackingTypeEnum.SERVICE_DETAIL).varScopeData(ruleJudgeRequest).startProcess(ProcessConfig::testSimpleFlowDemoProcess)
            .build();
    result = storyEngine.fire(fireRequest);
    Assert.assertTrue(result.isSuccess());
    Assert.assertEquals(15, (int) result.getResult());
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

testSimpleFlowDemo (opens new window)