Using LiteFlow Rule Engine for Business Process Orchestration in Java
This article introduces the LiteFlow lightweight rule engine, explains its architecture, component types, EL rule files, data context handling, configuration options, and demonstrates a real‑world e‑commerce workflow with code examples, while also noting related promotional offers at the end.
In daily development, serial or parallel business processes often need to be orchestrated without tight coupling. Combining strategy and template patterns can solve this, but code proliferation becomes a problem. A global‑view rule engine, LiteFlow, addresses these challenges.
LiteFlow is a lightweight yet powerful rule engine that can be used out‑of‑the‑box to compose complex rule flows quickly. It supports multiple rule file formats (XML, JSON, YAML) and storage options (SQL, Zookeeper, Nacos, Apollo).
Based on Spring Boot + MyBatis Plus + Vue & Element, the backend management system supports RBAC dynamic permissions, multi‑tenant, data permissions, workflow, third‑party login, payment, SMS, and e‑commerce features.
LiteFlow’s architecture allows defining chains of nodes where each node can execute business logic in various scripting languages (Groovy, JS, Python, Lua). Nodes are independent, and the engine can parse and register them at startup for high performance.
Components in LiteFlow include:
Ordinary Component – implements NodeComponent , used in when and then logic.
Switch Component – extends NodeSwitchComponent and overrides processSwitch to choose the next node, similar to a Java switch .
Condition Component – extends NodeIfComponent and overrides processIf to return true/false.
EL rule files are written in XML. Example snippets:
<flow>
<chain name="test_flow">
THEN(
prepareTrade, grantScore, sendMq, WHEN(sendEmail, sendPhone)
);
</chain>
</flow>Data context is crucial for passing parameters between nodes. Execution typically looks like:
LiteflowResponse response = flowExecutor.execute2Resp("chain1", initParam, CustomContext.class);Configuration in application.yml includes rule source path, retry count, execution logging, thread pool settings, and hot‑deployment options, e.g.:
liteflow:
ruleSource: liteflow/*.el.xml
retry-count: 0
print-execution-log: true
monitor:
enable-log: true
period: 300000
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: trueThe article then presents a business practice where, after an order is completed, points are granted, messages are sent, and SMS/email are dispatched in parallel using a LiteFlow chain.
In summary, most of LiteFlow’s work—rule parsing, component registration, and assembly—occurs at startup, delivering high execution performance while providing detailed timing and statistics. The tutorial covered LiteFlow’s core concepts and practical usage.
At the end, the author promotes a DeepSeek AI product bundle, a paid community, and various giveaways, encouraging readers to join for additional resources.
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.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.