LiteFlow, a lightweight component-based rule engine that is ready to use out of the box

LiteFlow, a lightweight component-based rule engine that is ready to use out of the box

2022-12-22 0 1,420
Resource Number 50083 Last Updated 2025-02-21
¥ 0USD Upgrade VIP
Download Now Matters needing attention
Can't download? Please contact customer service to submit a link error!
Value-added Service: Installation Guide Environment Configuration Secondary Development Template Modification Source Code Installation

This issue recommends a lightweight rule engine framework – LiteFlow.

LiteFlow, a lightweight component-based rule engine that is ready to use out of the box插图

In every company’s system, there are always some systems with complex business logic that carry core business logic, and almost every requirement is related to these core businesses. These core business logic are lengthy, involving internal logical operations, caching operations, persistence operations, external resource retrieval, internal RPC calls to other systems, and so on. Over time, as the project changes hands several times, the maintenance cost will become increasingly high. Various hard code judgments and branching conditions are increasing. The abstraction of code and the decreasing reuse rate result in high coupling between modules. A small logical change will affect other modules and requires complete regression testing to verify. If you want to flexibly change the order of business processes, you need to make major code changes to abstract and rewrite methods. Real time hot change business processes are almost difficult to implement.
How to break the deadlock? LiteFlow was born for decoupling logic and orchestration. After using LiteFlow, you will find that building a low coupling, flexible system becomes effortless!

Functional characteristics

  • Unified Component Definition: All logic is a component, providing a unified component implementation for all logic. Small in size, powerful.
  • Lightweight rules: Based on rule files to arrange processes, learning rules only takes 5 minutes to get started, and you can understand them at a glance.
  • Diversified rules: The rules support three ways of writing rule files: XML, JSON, and YML. Use whichever you like.
  • Arbitrary orchestration: synchronous asynchronous mixed orchestration, even the most complex logical process, can be easily achieved using LiteFlow’s rules. You can see how the logic works by looking at the rule files.
  • Rules can be loaded from anywhere: the framework provides implementations of local file configuration sources and zk configuration sources, as well as extension interfaces where you can store rules anywhere.
  • Elegant hot refresh mechanism: rule changes, no need to restart your application, instantly change the rules of the application. High concurrency will not cause any confusion in the executing rules due to refreshing the rules.
  • Wide support: Whether your project is built on Springboot, Spring, or any other Java framework, LiteFlow can handle it with ease.
  • JDK support: Supports everything from JDK8 to JDK17. No need to worry about JDK version.
  • Script language support: Script language nodes can be defined, supporting both QLExpress and Groovy scripts. More scripting languages will be supported in the future.
  • Rule nesting support: As long as you can think of it, you can use simple expressions to complete complex logic orchestration with multiple nesting.
  • Component retry support: Components can support retries, and each component can customize retry configurations and specify exceptions.
  • Context isolation mechanism: A reliable context isolation mechanism, you don’t have to worry about data streaming in high concurrency situations.
  • Declarative component support: You can make any of your classes instantly variable components.
  • Detailed step information: How your link is executed, how much time each component takes, what errors are reported, it is clear at a glance.
  • Stable and reliable: After more than 2 years of iteration, it runs stably on the core systems of major companies.
  • Excellent performance: The framework itself consumes almost no additional performance, and performance depends on the efficiency of your component execution.
  • Comes with simple monitoring: The framework comes with a command-line monitoring system that can determine the running time ranking of each component.

System Architecture

 

框架优势

如果你要对复杂业务逻辑进行新写或者重构,用LiteFlow最合适不过。它是一个轻量,快速的组件式规则引擎框架,组件编排,帮助解耦业务代码,让每一个业务片段都是一个组件,并支持热加载规则配置,实现即时修改。

LiteFlow利用规则表达式为驱动引擎,去驱动你定义的组件。你有想过类似以下的多线程流程编排该如何写吗?

LiteFlow, a lightweight component-based rule engine that is ready to use out of the box插图1 LiteFlow, a lightweight component-based rule engine that is ready to use out of the box插图2 LiteFlow, a lightweight component-based rule engine that is ready to use out of the box插图3

All of this is easy with LiteFlow! The expression language learning threshold of the framework is very low, but it can complete extremely complex orchestration.

Applicable scenarios

Not applicable to which scenarios:

LiteFlow only does logic based flow, not role-based task flow. If you want to do role-based task flow, we recommend using Flowable and Activiti frameworks.

Applicable to which scenarios:

LiteFlow is suitable for businesses with complex logic, such as price engines, ordering processes, etc. These businesses often have many steps that can be broken down into independent components according to business granularity for assembly, reuse, and change. By using LiteFlow, you will get a highly flexible and scalable system. Because the components are independent of each other, it can also avoid the risk of making changes that could affect the entire system.

Springboot Scene installation and operation

Dependency:

<dependency>
    <groupId>com.yomahub</groupId>
    <artifactId>liteflow-spring-boot-starter</artifactId>
    <version>2.8.2</version>
</dependency>

to configure:

Definition of Components:

1. After relying on the above jar packages, you need to define and implement some components to ensure that SpringBoot scans these components and registers them in the context

@Component("a")
public class ACmp extends NodeComponent {

	@Override
	public void process() {
		//do your business
	}
}

2. Repeat this process and define components b and c separately

@Component("b")
public class BCmp extends NodeComponent {

	@Override
	public void process() {
		//do your business
	}
}
@Component("c")
public class CCmp extends NodeComponent {

	@Override
	public void process() {
		//do your business
	}
}

SpringBoot configuration file:

Then, add the configuration in your SpringBoot’s application.exe or application-Yml (using properties as an example, YAML is the same)

liteflow.rule-source=config/flow.el.xml

Definition of Rule Files:

Meanwhile, you need to define rules in config/flow.exe under resources

<?xml version="1.0" encoding="UTF-8"?>
<flow>
    <chain name="chain1">
        THEN(a, b, c);
    </chain>
</flow>

SpringBoot automatically loads rule files at startup.

Execution:

Declaration of Startup Class:

@SpringBootApplication
//Scan the components you defined into the Spring context
@ComponentScan({"com.xxx.xxx.cmp"})
public class LiteflowExampleApplication {

    public static void main(String[] args) {
        SpringApplication.run(LiteflowExampleApplication.class, args);
    }
}

Then you can retrieve the flowExecutor from any Spring hosted class in Springboot and perform the execution process:

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

Tips:

This DefaultContext is the default context, and users can use any of their own beans as the context to pass in. If they need to pass in their own context, they need to pass in the Class property of the user bean. Please refer to the Data Context section for details.

Example

This case is a price calculation engine designed to simulate the calculation of order prices in e-commerce.

LiteFlow, a lightweight component-based rule engine that is ready to use out of the box插图4

—END—

Open source protocol:Apache2.0

资源下载此资源为免费资源立即下载
Telegram:@John_Software

Disclaimer: This article is published by a third party and represents the views of the author only and has nothing to do with this website. This site does not make any guarantee or commitment to the authenticity, completeness and timeliness of this article and all or part of its content, please readers for reference only, and please verify the relevant content. The publication or republication of articles by this website for the purpose of conveying more information does not mean that it endorses its views or confirms its description, nor does it mean that this website is responsible for its authenticity.

Ictcoder Free source code LiteFlow, a lightweight component-based rule engine that is ready to use out of the box https://ictcoder.com/kyym/liteflow-a-lightweight-component-based-rule-engine-that-is-ready-to-use-out-of-the-box.html

Share free open-source source code

Q&A
  • 1, automatic: after taking the photo, click the (download) link to download; 2. Manual: After taking the photo, contact the seller to issue it or contact the official to find the developer to ship.
View details
  • 1, the default transaction cycle of the source code: manual delivery of goods for 1-3 days, and the user payment amount will enter the platform guarantee until the completion of the transaction or 3-7 days can be issued, in case of disputes indefinitely extend the collection amount until the dispute is resolved or refunded!
View details
  • 1. Heptalon will permanently archive the process of trading between the two parties and the snapshots of the traded goods to ensure that the transaction is true, effective and safe! 2, Seven PAWS can not guarantee such as "permanent package update", "permanent technical support" and other similar transactions after the merchant commitment, please identify the buyer; 3, in the source code at the same time there is a website demonstration and picture demonstration, and the site is inconsistent with the diagram, the default according to the diagram as the dispute evaluation basis (except for special statements or agreement); 4, in the absence of "no legitimate basis for refund", the commodity written "once sold, no support for refund" and other similar statements, shall be deemed invalid; 5, before the shooting, the transaction content agreed by the two parties on QQ can also be the basis for dispute judgment (agreement and description of the conflict, the agreement shall prevail); 6, because the chat record can be used as the basis for dispute judgment, so when the two sides contact, only communicate with the other party on the QQ and mobile phone number left on the systemhere, in case the other party does not recognize self-commitment. 7, although the probability of disputes is very small, but be sure to retain such important information as chat records, mobile phone messages, etc., in case of disputes, it is convenient for seven PAWS to intervene in rapid processing.
View details
  • 1. As a third-party intermediary platform, Qichou protects the security of the transaction and the rights and interests of both buyers and sellers according to the transaction contract (commodity description, content agreed before the transaction); 2, non-platform online trading projects, any consequences have nothing to do with mutual site; No matter the seller for any reason to require offline transactions, please contact the management report.
View details

Related Article

make a comment
No comments available at the moment
Official customer service team

To solve your worries - 24 hours online professional service