Why LiteFlow Is the Go‑to Rule Engine for Complex Business Logic

LiteFlow is a lightweight, open‑source Chinese rule engine that transforms tangled if‑else code into modular, hot‑deployable components using a simple EL DSL, offering high performance, multi‑language scripting, and visual orchestration for backend systems.

Sohu Tech Products
Sohu Tech Products
Sohu Tech Products
Why LiteFlow Is the Go‑to Rule Engine for Complex Business Logic

LiteFlow is an open‑source lightweight rule engine that decouples complex business logic by splitting a waterfall‑style process into independent components (nodes) orchestrated with a DSL. Each component processes a single step and shares a common context (workbench), eliminating inter‑component method calls.

Key Capabilities

Component‑based decomposition : Long chains are broken into single‑purpose components.

Rule‑driven orchestration : EL expressions define serial, parallel, conditional and loop structures.

Multi‑language script support : Java, JavaScript, Groovy, QLExpress, Python, Lua, Aviator, etc. Java script compilation was accelerated 200× in v2.15.3 (30 s → 150 ms for 2000 scripts).

Hot deployment : Rules and scripts stored in DB or registries (Nacos, Etcd, Zookeeper) take effect instantly without restart.

Visual editor : LiteFlowX provides a drag‑and‑drop UI.

Built‑in monitoring : Command‑line monitor reports component execution time ranking.

Performance Highlights

Upgrading the underlying engine from QLExpress 3 to QLExpress 4 (v2.15.2) yields:

Compile TPS: 2,739 → 3,636 ops (+32%).

Context injection: 55,826 → 222,625 ops (+300%).

Benchmark used 2 warm‑up runs and 3 measured runs.

Quick Start

Maven Dependency

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

Supports JDK 8‑25; for JDK 9+ use v2.15.0+ without extra JVM arguments.

Rule File Configuration

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

Example resources/config/flow.el.xml:

<flow>
  <chain name="orderChain">
    THEN(
      validateOrder,
      WHEN(checkStock, calcPrice),
      riskCheck,
      saveOrder
    );
  </chain>
</flow>
THEN

denotes serial execution; WHEN runs its arguments in parallel.

Component Definition

@LiteflowComponent("validateOrder")
public class ValidateOrderCmp extends NodeComponent {
    @Override
    public void process() {
        OrderContext ctx = this.getContextBean(OrderContext.class);
        Order order = ctx.getOrder();
        if (order.getAmount() <= 0) {
            throw new IllegalArgumentException("订单金额必须大于0");
        }
        ctx.setValid(true);
    }
}

Components obtain shared data via getContextBean, avoiding explicit parameter passing.

Typical Use Cases

E‑commerce pricing engine : Separate base price, member discount, coupon, activity discount, final price calculation and persistence into distinct components; add new discount types by adding a component only.

Complex approval process : Implement business logic such as budget check, parallel supplier queries, risk rules, and order generation while delegating task routing to a BPM engine.

Data‑cleansing ETL : Componentize deduplication, format conversion, enrichment, and quality checks; configure different chains per data source.

Real‑time risk decision : Adjust fraud thresholds via hot‑deployed script changes without downtime.

EL Syntax Overview

Serial : THEN(a, b, c) or SER(a, b, c) Parallel : WHEN(a, b, c) or PAR(a, b, c) Nested : THEN(a, WHEN(b, THEN(c, d)), e) Ignore errors : WHEN(b, c, d).ignoreError(true) Any completion : WHEN(b, c, d).any(true) Must‑wait nodes : WHEN(b, c, d).must(b, c) Percentage completion :

WHEN(a, b, c, d, e).percentage(0.6)

When Not to Use

Pure role‑based approval flows (use Flowable/Flowlong).

Very simple 2‑3 step processes where the overhead outweighs benefits.

Massive parallel computations (hundreds of components) better suited for Spark/Flink.

Repository

https://gitee.com/dromara/liteFlow

LiteFlowX UI: https://gitee.com/liupeiqiang/LiteFlowX

Liquor dynamic compiler (used for Java script acceleration): https://gitee.com/noear/liquor

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaRule Enginebackend architectureLiteFlowHot Deploymentcomponent orchestrationEL DSL
Sohu Tech Products
Written by

Sohu Tech Products

A knowledge-sharing platform for Sohu's technology products. As a leading Chinese internet brand with media, video, search, and gaming services and over 700 million users, Sohu continuously drives tech innovation and practice. We’ll share practical insights and tech news here.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.