Backend Development 10 min read

Introducing LiteFlow: A Lightweight Java Flow Engine for Complex Business Logic

This article introduces LiteFlow, a lightweight yet powerful Java flow engine that enables developers to define complex business logic through concise rule files, demonstrates its key features, IDE plugin support, various orchestration expressions, and provides step‑by‑step integration examples with SpringBoot, code snippets, and a real‑world order‑price calculation use case.

IT Services Circle
IT Services Circle
IT Services Circle
Introducing LiteFlow: A Lightweight Java Flow Engine for Complex Business Logic

When building projects with complex business logic, using traditional if‑else statements can become verbose and hard to maintain. LiteFlow is a lightweight, powerful Chinese‑origin flow engine framework that allows developers to define business logic as reusable components and orchestrate them with simple rule files.

LiteFlow Overview

LiteFlow enables component‑based definition of logic using Spring annotations and supports rule files in XML, JSON, or YML formats. Its main features include unified component definition with @Component , lightweight rule syntax, support for synchronous and asynchronous mixing, hot‑reloading of rules, and compatibility with SpringBoot, Spring, or any Java project.

IDEA Plugin

LiteFlow provides an IDEA plugin called LiteFlowX that offers intelligent code completion, syntax highlighting, navigation between components and rule files, and a toolbox for quick access.

Rule Expressions

The engine offers several orchestration keywords:

Serial orchestration : THEN(a, b, c, d) executes components sequentially.

Parallel orchestration : WHEN(a, b, c) runs components concurrently.

Switch orchestration : SWITCH(a).to(b, c, d) mimics a switch statement.

Conditional orchestration : IF(x, a) executes a when x is true; IF(x, a, b) provides a ternary‑like behavior; IF(x, a).ELSE(b) and IF(x1, a).ELIF(x2, b).ELSE(c) support else if chains.

Sub‑processes : Define reusable sub‑chains and reference them in a main chain.

Integration Example – Order Price Calculation

The article walks through a complete SpringBoot integration:

Add the Maven dependency: <dependency> <groupId>com.yomahub</groupId> <artifactId>liteflow-spring-boot-starter</artifactId> <version>2.8.5</version> </dependency>

Configure rule file location in application.yml : liteflow: rule-source: liteflow/*.el.xml

Implement components by extending NodeComponent (e.g., CouponCmp ) or NodeSwitchComponent (e.g., PostageCondCmp ) and overriding process() and isAccess() methods.

Define rule files that compose the workflow, such as a promotion sub‑chain and the main chain that includes checks, initialization, discount calculations, and a final price result component.

Expose a controller that receives order data, invokes FlowExecutor.execute2Resp("mainChain", req, PriceContext.class) , and returns the computed price log.

All data is passed through a shared PriceContext object, which stores order details, intermediate price steps, and the final result.

Conclusion

LiteFlow simplifies the implementation of complex business processes, making the codebase clearer and easier to maintain. Its concise rule language and hot‑reload capability allow developers to get started within minutes, and the accompanying IDEA plugin further enhances productivity.

Javarule engineflow engineworkflowSpringBootLiteFlowbusiness-logic
IT Services Circle
Written by

IT Services Circle

Delivering cutting-edge internet insights and practical learning resources. We're a passionate and principled IT media platform.

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.