liteflow is a lightweight rule engine based on the workbench model, which decouples complex internal business logic through abstracted components, and can be applied in scenarios including complex business logic such as price, ordering, etc.
Here is a demonstration of how springboot integrates liteflow
1. Introduce dependencies
<dependency> <groupId></groupId> <artifactId>liteflow-spring-boot-starter</artifactId> <version>2.12.4.1</version> </dependency>
2. Add configuration in the application and specify the configuration file for rule arrangement
liteflow: rule-source: config/
3. Define the configuration file for rule arrangement and create a new file under resource/config
<?xml version="1.0" encoding="UTF-8"?> <flow> <chain name="chain1"> THEN(a, b); </chain> </flow>
4. Define the a and b components of the above components
@Component public class A extends NodeComponent { @Override public void process() throws Exception { ("A execute"); } }
@Component("b") public class B extends NodeComponent { @Override public void process() throws Exception { ("B execute"); } }
5. Execute the rule engine, and pass the rule name, chain1, and then call it by passing in the parameter.
@RestController public class LiteflowController { @Resource private FlowExecutor flowExecutor; @GetMapping("liteflow/test") public Result<String> liteflowTest(){ LiteflowResponse liteflowResponse = flowExecutor.execute2Resp("chain1", "arg"); return ("SUCCESS"); } }
This is the end of this article about the implementation example of springboot integrating liteflow. For more related springboot liteflow content, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!