Drool-based dynamic rule-based solutions, electronic devices, and readable storage media

By defining rule templates and dynamically generating Fact objects through reflection mechanisms, combined with a rule visualization page and cloud computing processing devices, the problem of low efficiency and difficult maintenance of rule engines in existing technologies is solved. This enables timely updates and releases of rules, improves system maintainability, and reduces the risk of hard coding.

CN115358402BActive Publication Date: 2026-03-10SHENZHEN QIANHAI HUANRONG LIANYI INFORMATION TECHNOLOGY SERVICES CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-29
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

In existing technologies, dynamic rule devices are inefficient, difficult to maintain, and require a service restart to take effect when rules change, which reduces the efficiency of rule engine usage.

Method used

By defining rule templates, fact objects can be generated manually or automatically using reflection. The rule library is managed using a rule visualization page. Fact objects are dynamically generated or updated using reflection. Fact objects are dynamically loaded into the rule engine through ClassLoader, enabling the updating of the relationship between rules and the rule engine. A rule visualization page is provided to manage the rule library, supporting the addition and updating of rules. The rule library is backed up locally and in internet cloud storage, and real-time data processing is performed using cloud computing devices.

Benefits of technology

It enables timely updates and release of rules without requiring service restarts, improving system maintainability and maintenance costs, reducing the costs and risks of hard-coded business rules, and enabling business analysts to participate in the editing and maintenance of rules.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115358402B_ABST
    Figure CN115358402B_ABST
Patent Text Reader

Abstract

This invention discloses a dynamic rule solution based on Drool, an electronic device, and a readable storage medium, relating to the field of data processing technology. The Drool-based dynamic rule solution includes the following steps: defining rule templates, manually defining or automatically generating fact objects using reflection, defining a rule base initialization class object, implementing an Application Listener, and executing rules. This Drool-based dynamic rule solution provides a rule visualization page for managing the rule base. The page offers functions for adding and updating rules. It dynamically generates or updates Fact objects using reflection, dynamically loads these Fact objects into the rule engine via ClassLoader, and updates the hash table relationship between the rules and the rule engine. This achieves timely rule updates and publishing, on-demand usage, and no need to reload services. The rule engine is relatively independent, focusing only on business rules, allowing business analysts to participate in editing and maintaining the system's business rules, reducing the cost and risk of hard-coding business rules.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data processing, in particular to a dynamic rule solving method based on drool, an electronic device and a readable storage medium. BACKGROUND

[0002] Rule engine is a technical solution to deal with a large number of rapidly changing business logic, which can execute reasoning logic according to certain algorithm to get the correct result according to the established fact and knowledge base. Rule engine is mainly composed of three parts: knowledge base, fact base and inference machine.

[0003] In actual work, we often encounter systems with complex business rules and frequent changes in business rules, such as risk control systems (risk loans, risk assessment), anti-fraud projects (bank loans, credit verification), decision platform systems (financial calculation), promotion platform systems (full price reduction, discount, price up), which need rule engine to solve, IT circle class and Drool similar to Aviator, Aviator is a high-performance, lightweight expression evaluation engine implemented in Java language, combined with API design to directly compile expressions into Java bytecode, and hand over to JVM for execution, as shown in the principle diagram Figure 1 As shown in the principle diagram, in the actual use process, there are the following shortcomings: the efficiency of the dynamic rule device is low, it is difficult to maintain, and it is difficult to cope with rule changes in the use process, and the modified code can only take effect after restarting the service, which greatly reduces the use efficiency of the rule engine; Therefore, we propose a dynamic rule solving method based on drool. SUMMARY

[0004] (I) Technical problems to be solved

[0005] In view of the deficiencies of the prior art, the present application provides a dynamic rule solving method based on drool, an electronic device and a readable storage medium to solve the problems mentioned in the background art.

[0006] (II) Technical solutions

[0007] In order to achieve the above purpose, the present application is realized by the following technical scheme: a dynamic rule solving method based on drool, the dynamic rule solving method comprises the following steps:

[0008] S1, define a rule template;

[0009] S2, manually define or reflect automatically code generation fact (Fact) object, define annotation rule (Rule), and bind the annotation rule with the fact object;

[0010] S3, defining a rule base initialization class object, implementing an Application Listener, scanning all fact objects bound to rule annotations by a processor when a service starts, declaring properties of the fact objects first, then saving full paths of the fact objects in a rule base, publishing rule base information to a drool rule engine (Rule Base) based on the rule template, the drool rule engine saving the published rules, establishing a relationship between rules in the rule base and the rule engine, and maintaining the relationship in a working memory hash table;

[0011] S4, executing the published rules, based on a rule matcher in an inference engine (Inference Engine), traversing the relationship between rules and the rule engine in the working memory hash table, obtaining a rule engine matching the published rules and storing it in a rule agenda (Agenda), and then executing the published rules through a processor.

[0012] Optionally, the rule base is internally managed through a rule visualization page, which provides functions of adding and updating a rule.

[0013] Optionally, the rule base dynamically generates or updates a Fact object based on a reflection mechanism, and publishes the Fact object to the rule engine through a class loader (ClassLoader), and updates the relationship between rules and the rule engine in the working memory hash table.

[0014] The drool-based dynamic rule solving method provides a rule visualization page to manage the rule base, the page provides functions of adding and updating a rule, dynamically generates or updates a fact object using a reflection mechanism, dynamically loads a Fact object to the rule engine through a class loader (ClassLoader), updates the hash table relationship between rules and the rule engine, and achieves timely updating and publishing of rules, immediate use, and no need to reload the service.

[0015] Optionally, in S3, a rule management page is provided in the working memory hash table, and when a certain rule expression is updated, the rule expression is automatically updated and published to the rule engine, and the working memory hash table is also updated.

[0016] Optionally, in the case of a single representation, the rule expression of the rule base uses one or more of an Aviator expression engine and an MVEL expression engine.

[0017] Optionally, the rule template is stored in the memory of the local computer and the Internet network disk, and the rule template is backed up in the memory of the local computer and the Internet network disk, and the rule template file in the memory of the local computer and the Internet network disk is checked at a unit check time.

[0018] Optionally, the unit check time is 1 hour.

[0019] Optionally, the processor comprises a cloud computing processing device, and the cloud computing processing device performs real-time data processing through the network module.

[0020] Optionally, the network module comprises at least one of a 5G network, a 4G network, a WiFi network and a local fiber network.

[0021] The drool-based dynamic rule solving method separates business rules from system code, realizes centralized management of business rules, improves system maintainability and maintenance cost, can extend and maintain business rules at any time without restarting the service, can dynamically modify business rules, quickly responds to demand changes, the rule engine is relatively independent, only concerns business rules, so that business analysts can also participate in editing and maintaining the business rules of the system, reduces the cost and risk of hard-coded business rules, and uses the rule editing tool provided by the rule engine to make the implementation of complex business rules simple.

[0022] The application further provides an electronic device comprising a processor and a memory storing a computer program, wherein the processor implements the steps of the drool-based dynamic rule solving method when executing the computer program.

[0023] The application further provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the processor implements the steps of the drool-based dynamic rule solving method when executing the computer program.

[0024] (Three) beneficial effects

[0025] The application provides a drool-based dynamic rule solving method, an electronic device and a readable storage medium.

[0026] (1) a rule visualization page is provided to manage the rule library, the page provides the function of adding and updating a rule, a Fact object is dynamically generated or updated by using a reflection mechanism, the Fact object is dynamically loaded by a Class Loader and published to the rule engine, the rule is updated and the hash table relationship with the rule engine is updated, so that the rule can be updated and published in time, used in time, and the service does not need to be reloaded.

[0027] (2) The business rules are separated from the system code, the centralized management of the business rules is realized, the system maintainability and maintenance cost are improved, the business rules can be extended and maintained at any time without restarting the service, the business rules can be dynamically modified, and the demand change can be quickly responded.

[0028] (3) The rule engine is relatively independent, only concerns the business rules, the business analysis personnel can also participate in editing and maintaining the business rules of the system, the cost and risk of hard-coding the business rules are reduced, the rule editing tool provided by the rule engine is used, and the implementation of the complex business rules becomes simple. BRIEF DESCRIPTION OF DRAWINGS

[0029] Figure 1 A flowchart processed by the rule engine in the prior art.

[0030] Figure 2 A flow structure schematic diagram of the present application. DETAILED DESCRIPTION

[0031] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.

[0032] It should be noted that all directional indications (such as up, down, left, right, front, back, etc.) in the embodiments of the present application are only used to explain the relative positional relationship, movement condition, etc. between components in a certain specific posture (as shown in the drawings), and if the specific posture changes, the directional indications also change accordingly.

[0033] Please refer to Figure 2 The present application provides a technical solution: a dynamic rule solving method based on drool, the dynamic rule solving method comprising the following steps:

[0034] S1, defining a rule template;

[0035] S2, manually defining or automatically generating a fact (Fact) object by reflection code, defining an annotation rule (Rule), and binding the annotation rule with the fact object;

[0036] S3, define rule base initialization class object, implement Application Listener, scan all binding rule (Rule) annotated fact objects through processor when service starts, first declare properties of fact objects, then save full path of fact objects in rule base, publish rule base information to drool rule engine based on rule template, drool rule engine saves published rules, establish relationship between rules in rule base and rule engine, maintain the relationship to working memory hash table, working memory hash table provides rule management page, when some rule expression exists update, the rule expression will be automatically updated and published to rule engine, and the working memory hash table will be updated together;

[0037] S4, execute the published rules, based on rule matcher in inference engine, traverse the relationship between rules and rule engine in the working memory hash table, get rule engine matched with the published rules and store them in rule agenda, then execute the published rules through processor.

[0038] In the embodiment, the rule base is internally managed through the rule visualization page. The rule visualization page provides the function of adding or updating a rule. The rule base dynamically generates or updates the Fact object based on the reflection mechanism, publishes the Fact object to the rule engine through the class loading ClassLoader, and updates the relationship between the rule and the rule engine hash table.

[0039] The dynamic rule solving method based on drool provides a rule visualization page to manage the rule base. The page provides the function of adding or updating a rule. The reflection mechanism is used to dynamically generate or update the Fact object. The Fact object is dynamically loaded to the rule engine through the class loading ClassLoader. The relationship between the rule and the rule engine hash table is updated. The rule is timely updated and published, used, and does not need to be reloaded.

[0040] Further, in the case of a single representation, the rule expression uses one or more of the Aviator expression engine and the MVEL expression engine.

[0041] Further, in order to monitor the rule template data in real time, the rule template is stored in the local computer memory and the Internet network disk, and the rule template is backed up in the local computer memory and the Internet network disk, and the unit check time is set to check the rule template file in the local computer memory and the Internet network disk. The unit check time is 1h. Through real-time monitoring of rule template data, it can be ensured that the data of the rule template will not be lost, which can ensure that the device can run stably and improve the processing efficiency of the data.

[0042] In order to ensure the processing efficiency of the data rule, the processor includes a cloud computing processing device, and the cloud computing processing device performs real-time data processing through a network module. The network module includes but is not limited to: 5G network, 4G network, WiFi network and local fiber network. In the case of damage of the processor in the local computer, the cloud computing processing device is used to realize real-time rule updating and publishing, so that the device can operate normally and stably.

[0043] The drool-based dynamic rule solving method separates the business rules from the system code, realizes centralized management of the business rules, improves the system maintainability and maintenance cost, can extend and maintain the business rules at any time without restarting the service, can dynamically modify the business rules, quickly responds to demand changes, and the rule engine is relatively independent and only concerns the business rules. Therefore, the business analysis personnel can also participate in editing and maintaining the business rules of the system, reduces the cost and risk of hard-coded business rules, and uses the rule editing tool provided by the rule engine to make the implementation of complex business rules simple.

[0044] The application also provides an electronic device comprising a processor and a memory storing a computer program, wherein the processor implements the steps of the drool-based dynamic rule solving method when executing the computer program. The application also provides a computer readable storage medium storing a computer program, wherein the computer program is executed by the processor to implement the steps of the drool-based dynamic rule solving method. When implementing the drool-based dynamic rule solving method, the rule visualization page is provided to manage the rule library, the page provides the function of adding or updating a rule, the Fact object is dynamically generated or updated by using the reflection mechanism, the Fact object is dynamically loaded by using the Class Loader and published to the rule engine, the rule is updated and the hash table relationship with the rule engine is updated, so that the rule is updated and published in time, used in time, and the service does not need to be reloaded.

[0045] While embodiments of the application have been shown and described, it is to be understood that the embodiments described are merely exemplary of the principles and application of the present application. Numerous modifications and adaptions can be effected without departing from the spirit and scope of the present application, which is not limited to the exact construction and arrangement described. It is intended, therefore, to cover all modifications and adaptions that fall within the scope of the claims and their equivalents.

Claims

1. A drool-based dynamic rules resolution method, characterized by: The dynamic rule solving method comprises the following steps: S1, defining a rule template; S2, manually defining or automatically generating a fact object by reflection, defining an annotation rule, and binding the annotation rule with the fact object; S3, defining a rule base initialization class object, implementing an Application Listener, and scanning all fact objects with bound rule annotations by a processor when a service starts, declaring properties of the fact objects, saving full paths of the fact objects in a rule base, publishing information stored in the rule base to a drool rule engine based on the rule template, saving the published rules by the drool rule engine, establishing a relationship between rules in the rule base and the rule engine, and maintaining the relationship in a working memory hash table; S4, executing the published rules, traversing the relationship between rules and the rule engine in the working memory hash table based on a rule matcher in an inference engine, obtaining rule engines matched with the published rules and storing the rule engines in a rule agenda, and executing the published rules by a processor.

2. The drool-based dynamic rules resolution method of claim 1, wherein: The rule base is internally managed by a rule visualization page, and the rule visualization page provides a function of adding or updating a rule.

3. The drool-based dynamic rules resolution method of claim 2, wherein: The rule base dynamically generates or updates fact objects based on a reflection mechanism, dynamically loads the fact objects to a rule engine by a class loader, and updates the relationship between rules and the rule engine in the working memory hash table.

4. The drool-based dynamic rules resolution method of claim 1, wherein: In S3, a rule management page is provided in the working memory hash table, and when a rule expression is updated, the rule expression is automatically updated and published to the rule engine, and the working memory hash table is updated.

5. The drool-based dynamic rules resolution method of claim 1, wherein: In the case of a single representation, the rule base uses one or more of an Aviator expression engine and an MVEL expression engine for rule expressions.

6. The drool-based dynamic rules resolution method of claim 1, wherein: The rule template is stored in a local computer memory and an Internet network disk, and is backed up in the local computer memory and the Internet network disk, and a unit check time is set to check data of the rule template files in the local computer memory and the Internet network disk.

7. The drool-based dynamic rules resolution method of claim 6, wherein: The unit check time is 1 hour.

8. The drool-based dynamic rules resolution method of claim 1, wherein: The processor comprises a cloud computing processing device, and the cloud computing processing device performs real-time data processing through a network module, and the network module comprises at least one of a 5G network, a 4G network, a WiFi network, and a local optical fiber network.

9. An electronic device, comprising: The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the steps of the dynamic rule solving method based on drool according to any one of claims 1-8.

10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the steps of the dynamic rule solving method based on drool according to any one of claims 1-8.

Citation Information

Patent Citations

  • Dynamic rule maintenance and generation method based on Drools

    CN110297620A

  • Rule engine parameter configuration method, device, computer equipment and storage medium

    CN110532041A