Backend Development 11 min read

Applying LiteFlow Component-Based Rule Engine for Lightweight Inspection Reports

This article explains how the LiteFlow component-based rule engine is used to design, configure, and execute flexible lightweight inspection reports, highlighting its modular architecture, real‑time component management, data context handling, and integration with configuration centers to reduce development overhead.

Zhuanzhuan Tech
Zhuanzhuan Tech
Zhuanzhuan Tech
Applying LiteFlow Component-Based Rule Engine for Lightweight Inspection Reports

1 Introduction

1.1 Background of Lightweight Inspection Reports

Last year the inspection capability for category N was launched, allowing the system to automatically package and consign items without manual checks. Traditional reports use fixed templates that cannot meet the flexible demands of category N, so a lightweight inspection report aims to provide a freely combinable and parsable format that ensures logical consistency and data accuracy.

1.2 Component‑Based Rule Engine and Its Potential

A component‑based rule engine splits rules into independent, reusable components that can be combined and configured to implement business logic. This modular approach reduces coupling, eases maintenance, and allows dynamic adjustment of rules without redeploying services.

Example: a coupon‑issuing scenario where four rule components (A‑D) are defined for user type, purchase amount, product category, and coupon stacking. These components are executed sequentially to determine the appropriate coupon.

2 Overview of the Component‑Based Rule Engine

2.1 Core Concepts and Features of LiteFlow

LiteFlow is a component‑based rule engine that enables flexible rule orchestration. Its core concepts include:

Component : Handles a specific rule or rule set.

Condition : Determines whether a rule should be triggered.

Action : Executes the business operation when the condition is met.

Orchestration : Defines the execution order and logic of multiple components.

Data Context : Shares data across components with thread‑local isolation.

Typical Java component example:

@Slf4j
@LiteflowComponent(FlowNodeVar.DYNAMIC_APPOINT)
public class DynamicAppointCmp extends NodeComponent {
  // condition
  isAccess();
  // action
  process();
}

Orchestration syntax example:

THEN (A,B,C,D)  // serial execution of four nodes.
WHEN (A,B,C,D)  // parallel execution of four nodes.
SWITCH(A).to(B, C, D)  // choose one of B, C, D based on A's result.
THEN(IF(X, A),B)  // if X is true execute A, otherwise execute B
....

The execution engine parses the defined flow, executes components in order, and manages data context sharing.

2.2 Why Choose LiteFlow for Lightweight Inspection Reports

Compared with other engines such as Drools or Easy‑Rules, LiteFlow offers real‑time component addition/removal, concurrent processing with isolated data contexts, hot‑refresh of rules from configuration centers (Apollo, Nacos, etc.) without restarting services, and built‑in monitoring of component execution times.

3 Design of the Lightweight Inspection Report Process

3.1 Overview of Rule and Chain Handling

During initialization, inspection report rules are stored in a configuration center (e.g., Apollo). A parser loads these rules into LiteFlow, which then builds the component nodes (A, B, C, …) and assembles the execution chain. The engine executes the chain according to request‑specific conditions, exchanging data via the shared context.

3.2 Configuring and Integrating LiteFlow in the Report

Integrate Data Sources and Services : Connect to configuration centers, RPC services, etc., to fetch required data for rule execution.

Design Rule Components : Define each component with its own condition, action, and data transformation logic, ensuring reusability.

Create Rule Flow : Arrange components in the desired order to define the execution flow.

Additional configurations, such as customizing icons and summary texts for specific inspection groups, are also managed through the configuration center.

4 Conclusion

The article presents a practical implementation of LiteFlow for lightweight inspection reports in the Zhaozhuan C2C & consignment business. Since the launch of inspection capability for category N, rule changes can be applied without redeployment, significantly reducing development effort.

About the author:

Zhao Lvtong, R&D Engineer, Zhaozhuan C2C & Consignment Business

Javarule engineBackend Developmentcomponent architectureLiteFlowInspection Report
Zhuanzhuan Tech
Written by

Zhuanzhuan Tech

A platform for Zhuanzhuan R&D and industry peers to learn and exchange technology, regularly sharing frontline experience and cutting‑edge topics. We welcome practical discussions and sharing; contact waterystone with any questions.

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.