美文网首页
流程编排LiteFlow

流程编排LiteFlow

作者: 我还是老油条 | 来源:发表于2023-05-18 17:33 被阅读0次
            <dependency>
                <groupId>com.yomahub</groupId>
                <artifactId>liteflow-spring-boot-starter</artifactId>
                <version>2.10.3</version>
            </dependency>
    

    2.新建三个流程类

    
    
    @Component("a")
    public class ACmp extends NodeComponent {
    
        @Override
        public void process() {
            System.out.println("111");
        }
    }
    
    @Component("b")
    public class BCmp extends NodeComponent {
    
        @Override
        public void process() {
            System.out.println("222");
        }
    }
    
    @Component("c")
    public class CCmp extends NodeComponent {
    
        @Override
        public void process() {
            System.out.println("333");
        }
    }
    
    

    3.在resources下的config/flow.el.xml中定义规则

    <?xml version="1.0" encoding="UTF-8"?>
    <flow>
        <chain name="chain1">
            THEN(a, b, c);
        </chain>
    </flow>
    
    1. application.properties
    liteflow.rule-source=config/flow.el.xml
    

    5.增加调用类

    @Component
    public class YourClass{
        
        @Resource
        private FlowExecutor flowExecutor;
        
        public void testConfig(){
            LiteflowResponse response = flowExecutor.execute2Resp("chain1", "arg");
        }
    
    
    }
    
    

    6.触发

    @RestController
    public class Controller {
    
        @Autowired
        YourClass yourClass;
    
        @GetMapping("/test")
        public void test() {
            yourClass.testConfig();
        }
    }
    

    7.效果


    image.png

    相关文章

      网友评论

          本文标题:流程编排LiteFlow

          本文链接:https://www.haomeiwen.com/subject/dyxgsdtx.html