Backend Development 11 min read

Introducing Liteflow: A Lightweight Rule Engine for Java Backend Development

This article presents Liteflow, a lightweight yet powerful rule engine for Java Spring Boot applications, covering its architecture, supported rule formats, component types, EL rule files, data context handling, configuration options, and a practical e‑commerce workflow example, while providing Maven dependency snippets and usage code.

Top Architect
Top Architect
Top Architect
Introducing Liteflow: A Lightweight Rule Engine for Java Backend Development

In daily development, serial or parallel business processes often lack correlation, making traditional coding cumbersome; Liteflow offers a global rule‑engine solution to orchestrate such workflows efficiently.

Liteflow is a lightweight, powerful rule engine that can be used out‑of‑the‑box with Spring Boot, MyBatis Plus, Vue & Element, supporting rule files in XML, JSON, or YAML, and storage options like SQL, Zookeeper, Nacos, or Apollo.

The engine’s architecture enables rule parsing at startup, component registration, and high‑performance execution, with optional hot‑deployment for real‑time rule updates.

Components are defined as nodes in rule files and include:

Ordinary components (implement NodeComponent ) for when/then logic, with methods such as process , iaAccess , isContinueOnError , and isEnd .

Switch components (extend NodeSwitchComponent ) to select the next node based on business logic, using processSwitch .

If components (extend NodeIfComponent ) to evaluate boolean conditions via processIf .

Rule files are typically written in EL XML syntax, for example:

# file orchestration, then for serial, when for parallel
THEN(a, b, c, d);
WHEN(a, b, c);
THEN(a, WHEN(b, c, d), e);
SWITCH(a).to(b, c);
THEN(IF(x, a), b);

The data context is crucial for passing parameters between nodes; it is created via the flow executor, e.g.:

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

Configuration in application.yml includes rule source paths, retry counts, logging, monitoring, request‑id generator, slot size, thread pool settings, and hot‑deployment flags.

A practical e‑commerce scenario demonstrates a chain that prepares a trade, grants score, sends a message queue, and concurrently sends email and SMS:

<flow>
    <chain name="test_flow">
        THEN(
            prepareTrade, grantScore, sendMq, WHEN(sendEmail, sendPhone)
        );
    </chain>
</flow>

The article concludes that most Liteflow work is completed at startup, offering high execution performance, detailed timing logs, and easy extension for complex workflows.

BackendJavarule engineWorkflowSpring BootLiteFlow
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

login 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.