Code Monkey home page Code Monkey logo

service-flow's Introduction

service-flow

微服务流程编排框架,支持方法节点、bean节点、条件节点(循环节点)、服务节点、子流程节点 功能视图

快速入门

依赖

版本按实际情况给定

<dependency>
    <groupId>com.service.flow</groupId>
    <artifactId>service-flow-spring-boot-starter</artifactId>
 </dependency>

定义输出参数DTO

需要继承BaseInput

public class TestInput extends BaseInput

定义输出参数DTO

需要继承BaseOutPut

public class TestOutput extends BaseOutput

定义流程临时变量

需要继承BaseTemp

public class TestTemp extends BaseTemp

定义组件

@Component("testComponent")
public class TestComponent {

     public TestOutput test1(TestInput test){
         TestOutput testOutput = new TestOutput();
         BeanUtils.copyProperties(test,testOutput);
         System.out.println("1111111111"+testOutput);
         return testOutput;
     }
......

}

流程定义

新增流程文件

在resources/flow下新建test.flow.yml 非注解方式

name: openAccount
id: test
desc: 条件执行
input: com.service.flow.sample.common.model.TestInput
output: com.service.flow.sample.common.model.TestOutput
temp: com.service.flow.sample.common.model.TestTemp
startNode: node1
nodes:
  - node:
      id: node1
      name: methodInvoke
      component: com.service.flow.sample.common.component.TestComponent:test1
      desc: 单节点执行
      input: com.service.flow.sample.common.model.TestInput
      type: method
      next: node2
  - node:
      id: node2
      name: beanInvoke
      component: testComponent:test2
      desc: 单节点执行
      input: com.service.flow.sample.common.model.TestInput
      type: bean
      next: node3
  - node:
      id: node3
      name: conditionByAge
      component: age>20:node4,age<20:node5
      desc: 条件节点执行
      type: condition
  - node:
      id: node4
      name: beanInvoke
      component: testComponent:test4
      desc: bean节点执行
      input: com.service.flow.sample.common.model.TestInput
      type: bean
  - node:
      id: node5
      name: beanInvoke
      component: testComponent:test5
      desc: bean节点执行
      input: com.service.flow.sample.common.model.TestInput
      type: bean
      next: node6
  - node:
      id: node6
      name: serviceInvoke
      component: /test:post:testApplication
      desc: 服务节点
      input: com.service.flow.sample.common.model.TestInput
      type: service
      next: node7
  - node:
      id: node7
      name: subFlow
      component: test2
      desc: 子流程节点
      input: com.service.flow.sample.common.model.TestInput
      type: subflow

注解方式

name: addCount
id: test6
desc: 方法节点执行
input: Test1Input
output: Test1Output
temp: Test1Temp
startNode: methodNode1
nodes:
    - node:
          id: methodNode1
          name: methodNode1
          component: count
          desc: 数量+1
          input: Test1Input
          type: method
          next: methodNode2
    - node:
          id: methodNode2
          name: methodNode2
          component: count
          desc: 数量+1
          input: Test1Input
          type: method
          next: methodNode3
    - node:
          id: methodNode3
          name: methodNode3
          component: count
          desc: 数量+1
          input: Test1Input
          type: method


执行结果

2020-06-22 22:43:30.607  INFO 7276 --- [           main] com.service.flow.web.api.FlowHandler     : result:Test{name='zhangsan', age=18}
2020-06-22 22:43:30.607  INFO 7276 --- [           main] com.service.flow.web.api.FlowHandler     : record:Flow:test2->Node:node1
2020-06-22 22:43:30.607  INFO 7276 --- [           main] com.service.flow.web.api.FlowHandler     : totalTime:0ms
2020-06-22 22:43:30.607  INFO 7276 --- [           main] com.service.flow.web.api.FlowHandler     : result:Test{name='zhangsan', age=18}
2020-06-22 22:43:30.607  INFO 7276 --- [           main] com.service.flow.web.api.FlowHandler     : record:Flow:test->Node:node1->Node:node2->Node:node3->Node:node5->Node:node6->Node:node7
2020-06-22 22:43:30.607  INFO 7276 --- [           main] com.service.flow.web.api.FlowHandler     : totalTime:52ms

相关示例


相关文章

service-flow's People

Contributors

zhangchangb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.