English | δΈζ
Eport Daemon Rule Engine is an enterprise-grade rule engine system built for port management operations. It provides a unified framework supporting both Drools and LiteFlow rule engines, enabling flexible business rule management and execution in distributed microservice environments.
The system is designed to handle complex business logic validation, data processing workflows, and automated decision-making processes commonly found in port and logistics management systems.
- π Dual Rule Engine Support: Native support for both Drools and LiteFlow rule engines
- ποΈ Microservice Architecture: Built on Spring Cloud with Nacos service discovery
- π Flexible Rule Loading: Support for local file system and Redis-based rule storage
- π Enterprise Integration: Seamless integration with existing Eport ecosystem
- π‘οΈ Security & Authentication: Built-in OAuth2 and JWT security mechanisms
- π Performance Monitoring: Comprehensive logging and monitoring capabilities
- π³ Container Ready: Docker support for easy deployment
- π§ Hot Reload: Dynamic rule reloading without service restart
- Java 21: Latest LTS version with modern language features
- Spring Boot 3.x: Enterprise application framework
- Spring Cloud 2023.x: Microservice infrastructure
- Nacos: Service discovery and configuration management
- Drools 10.1.0: Business rule management system
- LiteFlow 2.15.0: Lightweight rule orchestration engine
- MyBatis Plus: Enhanced ORM framework
- MySQL/MSSQL/Oracle/PostgreSQL: Multi-database support
- Druid: High-performance connection pool
- Redis: Caching and rule storage
- Docker: Containerization
- Undertow: High-performance web server
- Maven: Build and dependency management
- JDK 21+: Required for compilation and runtime
- Maven 3.6+: For project build management
- Docker: Optional, for containerized deployment
- Nacos Server: For service registration and configuration
- Clone Repository
git clone https://github.com/your-org/eport-rule-engine.git
cd eport-rule-engine- Build Project
# Build all modules
mvn clean package
# Build specific profile
mvn clean package -P cloud- Configure Services
Update application.yml in the starter module:
spring:
cloud:
nacos:
discovery:
server-addr: localhost:8848
config:
server-addr: localhost:8848- Run Application
# Run from starter module
cd eport-rule-engine-starter
java -jar target/eport-rule-engine-starter-5.9.0.jar# Build Docker image
cd eport-rule-engine-starter
docker build -t eport-rule-engine:latest .
# Run container
docker run -d \
--name eport-rule-engine \
-p 19992:19992 \
-e NACOS_HOST=your-nacos-server \
eport-rule-engine:latesteport-rule-engine/
βββ eport-rule-engine-core/ # Core rule engine implementation
β βββ src/main/java/
β β βββ com/eport/daemon/rule/
β β βββ common/ # Common constants and enums
β β βββ engine/ # Rule engine abstractions
β β β βββ impl/ # Drools and LiteFlow implementations
β β β βββ AbstractRuleEngine.java
β β β βββ RuleEngine.java
β β β βββ RuleEngineBuilder.java
β β β βββ RuleEngineFactory.java
β β βββ pojo/ # Data models
β β βββ storage/ # Rule storage and loading
β β β βββ impl/ # Local and Redis implementations
β β βββ utils/ # Utility classes
β βββ pom.xml
βββ eport-rule-engine-starter/ # Spring Boot application starter
β βββ src/main/java/
β β βββ com/eport/daemon/rule/
β β βββ EportDaemonRuleEngineApplication.java
β β βββ liteflow/ # LiteFlow components
β βββ src/test/ # Test cases and examples
β β βββ java/ # Unit tests
β β βββ resources/rules/ # Sample rules
β β βββ drools/ # Drools rule files (.drl)
β β βββ liteflow/ # LiteFlow rule files (.xml)
β βββ Dockerfile
β βββ pom.xml
βββ pom.xml # Parent POM
βββ LICENSE
βββ README.md
βββ README_CN.md
The system supports multiple rule engines through the EngineType enumeration:
DROOLS: Traditional rule-based engine for complex business logicLITEFLOW: Lightweight orchestration engine for workflow management
Configure rule loading strategy in your application:
- Local File System: Load rules from classpath or file system
- Redis: Centralized rule storage with hot reload capabilities
The system supports multiple database types:
- MySQL
- Microsoft SQL Server
- Oracle Database
- PostgreSQL
package rules.engine.set.ruleset1
import com.alibaba.fastjson.JSONObject
rule "vehicle_weight_check"
when
$fact:JSONObject(getInteger("weight") != null && getInteger("weight") >= 60)
then
$fact.put("overweight", 1);
System.out.println("Vehicle is overweight");
end
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<chain name="validation_chain">
THEN(weight_check, cargo_check, WHEN(special_check, standard_check));
</chain>
</flow>Run the test suite to verify functionality:
# Run all tests
mvn test
# Run specific test classes
mvn test -Dtest=SimpleLiteFlowTest
mvn test -Dtest=SimpleServiceTestThe service exposes RESTful APIs under the /admin context path:
- Base URL:
http://localhost:19992/admin - API Documentation: Access Swagger UI at
/admin/swagger-ui.html
- Spring Boot Actuator endpoints
- Custom health indicators for rule engines
- Structured logging with Logback
- Configurable log levels per component
- Integration with centralized logging systems
- Application performance metrics
- Rule execution statistics
- System resource monitoring
- OAuth2 Authentication: Secure API access
- JWT Token Support: Stateless authentication
- Role-based Authorization: Fine-grained access control
- API Encryption: Request/response encryption support
We welcome contributions to improve the Eport Rule Engine! Please follow these guidelines:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow Java coding standards and best practices
- Write comprehensive unit tests for new features
- Update documentation for API changes
- Ensure backward compatibility when possible
This project is licensed under the MIT License - see the LICENSE file for details.
Project Maintainer: @HeyAlaia
- Email: [email protected]
- Blog: alaiablog.pages.dev
Enterprise Support: Contact our enterprise team for commercial support and customization services.
