Introducing Liteflow: A Lightweight Rule Engine for Complex Workflow Orchestration

This article presents Liteflow, a lightweight yet powerful rule engine that enables developers to define and execute complex serial, parallel, switch, and conditional workflows using XML/JSON/YAML rule files, supports hot‑deployment, and integrates seamlessly with Spring Boot for high‑performance backend services.

Top Architect
Top Architect
Top Architect
Introducing Liteflow: A Lightweight Rule Engine for Complex Workflow Orchestration

Hello, I am a senior architect.

1 Preface

In daily development we often encounter serial or parallel business processes that are unrelated. Using strategy and template patterns can solve this, but many files are generated. This article introduces a global solution using the Liteflow rule engine.

2 Liteflow Rule Engine

Liteflow is a lightweight yet powerful rule engine that works out‑of‑the‑box and can orchestrate complex rules quickly. It supports XML, JSON, and YAML rule files and can store them in SQL, Zookeeper, Nacos, Apollo, etc.

Liteflow executes by obtaining a data context, parsing the rule file, and running a chain where each node is an independent business component that can be written in Groovy, JavaScript, Python, Lua, etc.

Official website: https://liteflow.yomahub.com

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

Liteflow can handle complex flows such as:

It also supports hot‑deployment, allowing rule files to be changed at runtime.

3 How to Use Liteflow

3.1 Components

Components correspond to nodes in rule files. Types include:

Ordinary Component – implements NodeComponent, used in when/then logic, overrides iaAccess, isContinueOnError, isEnd.

Switch Component – decides the next node, similar to Java switch, implements NodeSwitchComponent and overrides processSwitch.

If Component – conditional node, implements NodeIfComponent and overrides processIf.

# flow rule expression switch component
SWITCH(a).to(b, c);
# processSwitch must return "b" or "c"
# flow rule expression condition component
IF(x, a, b);

3.2 EL Rule Files

Rule files are usually written in XML. Example snippets:

# serial composition
THEN(a, b, c, d);
# parallel composition
WHEN(a, b, c);
# nested composition
THEN(a, WHEN(b, c, d), e);
# switch composition
SWITCH(a).to(b, c, d);
# condition composition
THEN(IF(x, a), b);

3.3 Data Context

Data context carries parameters between nodes. Execution example:

LiteflowResponse response = flowExecutor.execute2Resp("chain1", initialParams, CustomContext.class);

3.4 Parameter Configuration

Configuration items include rule file location, retry count, thread pool for parallel execution, request‑id generator, slot size, etc. Example:

liteflow:
  ruleSource: liteflow/*.el.xml
  retry-count: 0
  print-execution-log: true
  monitor:
    enable-log: true
    period: 300000
  request-id-generator-class: com.platform.orderserver.config.AppRequestIdGenerator
  slot-size: 10240
  main-executor-works: 64
  when-max-wait-seconds: 15
  when-max-workers: 16
  when-queue-limit: 5120
  parse-on-start: true
  enable: true

4 Business Practice

Example: after an order is completed, grant points, send a message, and send email and SMS in parallel.

<?xml version="1.0" encoding="UTF-8"?>
<flow>
    <chain name="test_flow">
        THEN(
            prepareTrade, grantScore, sendMq, WHEN(sendEmail, sendPhone)
        );
    </chain>
</flow>

Pre‑processing converts input parameters into a context object, and each business step is implemented as a node component.

5 Summary

Liteflow performs most work at startup—parsing rules, registering components, assembling information—so runtime performance is high. The article introduced Liteflow’s concepts, usage, and provided sample code. The source code is available on GitHub.

Project GitHub address: springboot-auth https://github.com/thedestiny/springboot-auth/tree/main/order-server

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.

rule engineworkflowBackend DevelopmentLiteFlow
Top Architect
Written by

Top Architect

Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.

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.