Master LiteFlow: Build Scalable Component‑Based Workflow Engines in Java

This article introduces LiteFlow, a lightweight Java component‑based rule engine that decouples complex business logic, explains its workbench design, demonstrates usage in both non‑Spring and SpringBoot environments with Maven setup and XML configuration, and details its core components, parsing, chain execution, and node processing.

Su San Talks Tech
Su San Talks Tech
Su San Talks Tech
Master LiteFlow: Build Scalable Component‑Based Workflow Engines in Java

LiteFlow Framework Overview

LiteFlow is a lightweight, fast, stable, component‑based rule engine designed to decouple complex business logic. It allows developers to split business code into reusable components, define a rule flow configuration, and achieve hot‑loading of rules.

Design Principles

LiteFlow follows the “workbench” model: each worker (component) processes its own piece of work using resources from a shared context, without needing to know about other workers. This provides decoupling, stability, reusability, and real‑time reconfiguration.

Using LiteFlow

Non‑Spring Environment

1. Add the Maven dependency:

<dependency>
   <groupId>com.yomahub</groupId>
   <artifactId>liteflow-core</artifactId>
   <version>2.6.13</version>
</dependency>

2. Implement a business node by extending NodeComponent and overriding process.

3. Place the XML rule file under resources and configure <nodes/>, <chain/>, <when/>, <then/> etc.

4. Build a LiteflowConfig with the XML path, create a FlowExecutor, and call execute2Resp(chainId).

SpringBoot Environment

1. Add the starter dependency:

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

2. Annotate node classes with @LiteflowComponent; no explicit <node/> entries are required.

3. Configure the XML rule file location in application.properties.

4. Run the demo; the execution result matches the non‑Spring case.

Core Components

Parser : Parses rule files (XML/JSON/YAML) into Java objects (Node, Chain, Condition). Supports multiple file types and storage back‑ends (local, ZK, custom).

FlowBus : Stores parsed Nodes and Chains for later execution.

FlowExecutor : Retrieves a Chain from FlowBus and drives its execution via executePre, execute, and executeFinally.

Slot : Shared context for a flow, holding parameters and results.

DataBus : Manages Slot instances.

Parsing Process

The parser reads each rule file, converts it to a DOM document, and extracts <node> definitions to build Node objects, then parses <chain> elements, creating Conditions ( PreCondition, ThenCondition, WhenCondition, FinallyCondition) and assembling them into Chains.

Chain Execution Flow

FlowExecutor obtains the target Chain, executes pre‑conditions, then iterates through Conditions. ThenCondition runs Nodes sequentially, while WhenCondition runs Nodes in parallel. Finally, FinallyCondition is executed.

Node Execution

Each Node wraps a NodeComponent. The executor checks isAccess, obtains a NodeExecutor, and calls the component’s process method. Retry logic is built into the executor, but the final call always reaches NodeComponent.process. The Slot is updated with results after each Node.

Architecture Diagram

LiteFlow architecture
LiteFlow architecture
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 engineSpring BootComponent ArchitectureLiteFlowWorkflow Engine
Su San Talks Tech
Written by

Su San Talks Tech

Su San, former staff at several leading tech companies, is a top creator on Juejin and a premium creator on CSDN, and runs the free coding practice site www.susan.net.cn.

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.