Distributed rule engine using method based on micro-service and rule engine

Through the distributed rules engine based on microservices, the problem of difficulty in scaling and complex configuration in the existing software development model is solved, and the flexible expansion of the rules engine and efficient processing of complex business rules is achieved, which reduces the customization cost of software development.

CN119536710AActive Publication Date: 2025-02-28JIANGSU HANBANGTANG TECHNOLOGY CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202411602597.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-11
Publication Date
2025-02-28
Estimated Expiration
2044-11-11

AI Technical Summary

Technical Problem

The existing software development model has problems such as the difficulty of expanding on stand-alone deployment, the single triggering method does not support hot updates and sub-rules, and the technical threshold for complex configurations is high, resulting in high R&D costs and long project cycles.

Method used

A distributed rule engine based on microservices is adopted to configure the logical execution node graph and trigger method for rule execution through a visual web interface, supporting dynamic expansion, hot rule updates and subrules, and providing diversified trigger methods.

Benefits of technology

It realizes the flexible expansion of the rule engine and efficient handling of complex business rules, reduces the customization cost of software development, and provides a more flexible, efficient and economical software development solution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119536710A_ABST
    Figure CN119536710A_ABST
Patent Text Reader

Abstract

The invention discloses a micro-service-based distributed rule engine use method and a rule engine, and belongs to the technical field of rule engines. The method comprises the following steps: S1, configuring a logic execution node graph executed by a rule through a visual web interface, and then configuring a trigger mode of the rule; s2, after correspondingly executed node configuration is completed, a trigger triggers an instruction, and rules are executed according to the received instruction and request parameters; and S3, after the rule is executed, storing an execution log of the rule. According to the invention, low-code visual configuration is realized, so that non-technical personnel can easily realize business rules; the micro-service deployment is realized, the expansion is more convenient, the updating speed is high, and the management is more convenient; moreover, the method is diversified in triggering mode, does not need to restart the service, achieves the online configuration according to the personalized demands, achieves the third-party butt joint, reduces the cost, and improves the efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of rule engines, and in particular relates to a method for using a distributed rule engine based on microservices and a rule engine. Background Art

[0002] With the intensification of market competition and the diversification of customer needs, software development projects often require a lot of customized development to meet specific business needs. This customized development is not only time-consuming and labor-intensive, but also increases the complexity of the project and the difficulty of subsequent maintenance, resulting in a significant increase in R&D costs.

[0003] During software development, it is often necessary to connect with third-party systems or services. These third-party systems may have different data formats, interface protocols, and business logic, making the connection work complicated and cumbersome. Traditional software development models often require the development of separate interfaces for each third-party system, which not only increases the development workload, but also prolongs the project cycle, further increasing R&D costs.

[0004] The existing technical solutions for software development currently have the following shortcomings / deficiencies:

[0005] 1. Single-machine deployment is not easy to dynamically expand according to business volume;

[0006] 2. The triggering method is single and does not support hot update of rules and sub-rules;

[0007] 3. The configuration is complex and the technical threshold is high, making it difficult for ordinary non-technical users to get started. Summary of the invention

[0008] In view of the deficiencies in the prior art, the present invention provides a method for using a distributed rule engine based on microservices and a rule engine, which can manage and configure rules through visualization and can be dynamically expanded to more efficiently process complex business rules, simplify third-party docking rules, and reduce the customization cost of software development; providing enterprises with a more flexible, efficient and economical software development solution.

[0009] Technical solution: In order to solve the above technical problems, the technical solution adopted by the present invention is as follows:

[0010] A method for using a distributed rule engine based on microservices includes the following steps:

[0011] S1: Configure the logical execution node diagram of rule execution through the visual web interface, and then configure the triggering method of the rule;

[0012] S2: After the corresponding execution node configuration is completed, the trigger triggers the instruction and executes the rule according to the received instruction and request parameters;

[0013] S3: After the rule execution is completed, the rule execution log is saved.

[0014] Preferably, in S1, the logical execution node diagram of the rule execution is configured through a visual web interface, and then the specific content of the triggering mode of the rule is configured as follows:

[0015] Triggering methods include fixed time triggering, form time triggering, process triggering, data triggering, and MQ triggering;

[0016] Fixed time trigger: set a cycle time, and execute the planned rules every time a cycle time is reached;

[0017] Form time trigger: Select the date and time field in a table of a product application, and configure the trigger time point before or after the time value of all records in the table. The rule can be triggered every cycle.

[0018] Process trigger: set the approval process data record change trigger and execute the configured rules;

[0019] Data trigger: set a product application table to have data changes, and automatically execute the set rules;

[0020] MQ trigger: When the external system is set to pass information to the rule engine platform through related operations or data changes, the platform will execute the corresponding rules based on the relevant information.

[0021] Preferably, in S2, after the corresponding execution node configuration is completed, the trigger triggers the instruction, and the specific content of executing the rule according to the received instruction and request parameters is:

[0022] The publishing rules include: verifying the availability of the rule logic diagram. If the verification passes, the publishing is successful and a publishing version is generated; otherwise, the publishing fails and the reason for the failure of the rule publishing is prompted.

[0023] Preferably, after the triggering condition for executing the rule is met: the rule is executed according to the node configured in the rule logic diagram to determine whether it is an ending node, if not, continue to execute; if yes, the rule execution ends.

[0024] Preferably, in the rule for executing the configuration node, the execution modes supported by the sub-rules include sequential execution or concurrent execution;

[0025] Sequential execution: The sub-rules have a certain order relationship with the subsequent nodes, so they are executed sequentially;

[0026] Concurrent execution: If the node does not use the return data of the sub-rule, select concurrent execution.

[0027] As a preferred embodiment, it includes a WEB visualization configuration module, an execution module and a rule statistics module;

[0028] The WEB visualization configuration module includes the WEB visualization rule editing module and the WEB visualization trigger configuration module;

[0029] The execution module includes a rule execution module and a trigger execution module.

[0030] Preferably, the WEB visual rule editing module is used for flexible matching of multiple node modules, which are arranged and assembled into a rule chain from top to bottom without restarting, and can be called and executed by triggers after hot loading;

[0031] The WEB visualization trigger configuration module is used to configure various trigger conditions of the platform and which rule to trigger;

[0032] The trigger execution module includes timed task monitoring, http interface monitoring, message queue monitoring, addition, deletion, modification and query monitoring, process approval monitoring, and form time monitoring; when triggered, the message is passed to the corresponding rule execution module through the message queue for execution;

[0033] The rule execution module is used to execute the message passed by the trigger as an input parameter, and execute each node module according to the configured rule chain and data flow conditions;

[0034] The rule statistics module is used to count the number of times different rule triggering methods are used within a certain time range, the line chart analysis of the maximum, minimum and average time consumption, and the line chart analysis of success, failure and total number of times.

[0035] An electronic device comprises: a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the above method.

[0036] A computer-readable storage medium stores computer-readable instructions, which can be executed by a processor to implement the above method.

[0037] Beneficial effects: Compared with the prior art, the present invention has the following advantages:

[0038] (1) The present invention realizes microservice deployment, which is more convenient to expand, update faster, and manage more conveniently.

[0039] (2) The present invention realizes low-code visual configuration, allowing non-technical personnel to easily implement business rules.

[0040] (3) The present invention has a variety of triggering methods, supporting the addition, modification, deletion of data triggers, timing triggers, data triggers of a certain field time in the database, HTTP triggers, MQ message queue triggers or flowable rule engine triggers; there is no need to restart the service, and online configuration can be performed according to personalized needs to achieve third-party docking, reduce costs and increase efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 It is a flow chart of a method for using a distributed rule engine based on microservices of the present invention.

[0042] Figure 2 It is an internal structure diagram of the microservice-based distributed rule engine of the present invention;

[0043] Figure 3 It is a data flow diagram of the distributed rule engine based on microservices of the present invention. DETAILED DESCRIPTION

[0044] The present invention is further illustrated below in conjunction with specific examples. The examples are implemented based on the technical solutions of the present invention. It should be understood that these examples are only used to illustrate the present invention and are not used to limit the scope of the present invention.

[0045] A distributed rule engine based on microservices is a software system that can automatically execute decisions based on predefined business rules. By using a rule engine, developers can separate business logic from program code and use easy-to-understand and easy-to-modify rule sets to control the behavior of the software. This approach not only improves the flexibility and maintainability of the software, but also reduces the development costs caused by business changes.

[0046] like Figure 1 As shown, the method for using the distributed rule engine based on microservices provided in this embodiment includes the following steps:

[0047] S1: Configure the logical execution node diagram of rule execution through the visual web interface, and then configure the triggering method of the rule;

[0048] Nodes include one or more of the following: data addition, deletion, modification and query, message notification, calling external or internal services, operating redis cache, sending mq message queues, sub-rules, field calculations, conditional branches, loops, associations, aggregations and custom scripts.

[0049] Data addition, deletion, modification and query node: You can select a business table in the database to perform operations such as addition, deletion, modification and query.

[0050] Message notification node: You can set email, message notification, SMS, DingTalk, etc., and call the message notification module through microservices to notify the corresponding users of the message.

[0051] Internal service node: can be configured to call all microservices in the registry.

[0052] External service node: can be configured to call the external interface service of the http protocol.

[0053] Cache node: can be configured to read or write data to redis (Remote Dictionary Server).

[0054] Message queue node: can be configured to send data to a specified switch or message queue.

[0055] Sub-rule node: You can configure existing rules to achieve rule reuse and simplify configuration.

[0056] Field calculation node: The calculation result can be assigned to other application tables or used as a flow condition.

[0057] Conditional branch node: You can configure the data to follow different rule chains when they meet different conditions.

[0058] Loop node: You can configure iterative loops, fixed loops, and conditional loops. The loop body node configuration is similar to sub-rules.

[0059] Association node: can aggregate two dataset objects into a new dataset based on the association fields and connection methods.

[0060] Aggregation node: Filters qualified data from worksheets or upstream dataset nodes and performs summary calculations.

[0061] Such as: record quantity, sum, average, maximum, minimum, etc.

[0062] Custom nodes: You can configure groovy, java, and js scripts without restarting, and hot loading takes effect immediately.

[0063] The triggering methods include one or more of the following: triggering by adding, modifying, or deleting data, triggering by a fixed period, triggering by data in a certain field of a database, triggering by http (Hypertext Transfer Protocol), triggering by MQ (Message Queue) message queue, or triggering by flowable (an open source business process management (BPMS) platform) rule engine.

[0064] Fixed time (cycle) trigger: You can set a cycle time (for example, 9 am every Monday), and the planned rules can be executed every time a cycle time is reached.

[0065] For example, if the company holds a weekly meeting at 3 pm every Friday, a rule can be set to be triggered at 2:30 pm every Friday to remind employees to prepare for the meeting.

[0066] Form time trigger: You can select the date and time field in a table of a product application, and configure the trigger time point before or after the time value of all records in the table. The rule can be triggered every cycle.

[0067] For example, the employee table records the birthday of each employee. When an employee's birthday comes at 8 a.m., a rule is triggered to send a text message to the employee to wish him or her a happy birthday.

[0068] Process trigger: You can set the approval process data record change trigger to execute the configured rules.

[0069] For example, after the incoming order review node agrees, a rule is triggered to automatically increase the product inventory quantity.

[0070] Data trigger: When there is a data change in a product application table, the set rules will be automatically executed.

[0071] For example, when new data is added to the employee table, a rule is triggered to update the address book and send emails with the latest address book information to all old employees.

[0072] MQ trigger: You can set the external system to pass information to the rule engine platform when related operations or data changes are performed, and the platform will execute corresponding rules based on the relevant information.

[0073] For example, after an order is added and confirmed in the CRM system, a rule for the outbound application process is simultaneously initiated in the inventory management system.

[0074] S2: After the corresponding execution node configuration is completed, once the trigger triggers the instruction, the rule is executed according to the received instruction and request parameters;

[0075] Publishing rules includes the following steps: verifying the availability of the rule logic diagram. If the verification passes, the publishing is successful and a publishing version is generated; otherwise, the publishing fails and the reason for the failure of the rule publishing is prompted.

[0076] After the triggering condition for executing the rule is met, the following steps are also included: executing the rule according to the node configured in the rule logic diagram, judging whether it is the end node, if not, continuing to execute; if yes, the rule execution ends.

[0077] In the rule of executing the configuration node, the execution modes supported by the sub-rules include one or more of the following modes: sequential execution or concurrent execution.

[0078] Sequential execution: If the sub-rule has a strict sequential relationship with the subsequent nodes, sequential execution is selected.

[0079] For example, if the subsequent node needs to use the data returned by the sub-rule to perform the next action, it is necessary to execute sequentially and wait for the sub-rule to be executed before executing the subsequent rule node.

[0080] Concurrent execution: If the node does not use the return data of the sub-rule, select concurrent execution to improve the execution efficiency of the rule.

[0081] For example, scenarios with sub-rules such as logging and message notification.

[0082] S3: After the rule execution is completed, the rule execution log is saved.

[0083] The following is an example of the use of the distributed rule engine based on microservices provided in the embodiment of the present application. For example, in the following scenario: during the "equipment inspection", the faulty equipment information and fault information are synchronized to the "equipment maintenance application". Specifically:

[0084] Step 1: Add a new rule named "Device Inspection" through the visual web interface;

[0085] Step 2: Add a new data node and name it "New Maintenance Application", set the table to Equipment Maintenance Application Form, and assign the fields to Device Name = Request Parameter.Device Name, Device Number = Request Parameter.Device Number, and Device Status = Request Parameter.Device Status;

[0086] Step 3: Click to publish the rule;

[0087] Step 4: Add a new trigger as data trigger, select the table equipment inspection, and trigger when new data is added and the device status is equal to failure. Set the binding "equipment inspection" rule.

[0088] like Figure 2 As shown, the distributed rule engine based on microservices provided in this embodiment includes a WEB visualization configuration module, an execution module and a rule statistics module.

[0089] The WEB visualization configuration module includes the WEB visualization rule editing module and the WEB visualization trigger configuration module.

[0090] The WEB visual rule editing module is used for flexible matching based on various node modules, arranging and assembling into rule chains from top to bottom, without restarting, and can be called and executed by triggers after hot loading.

[0091] The WEB visualization trigger configuration module is used to configure various trigger conditions of the platform and which rule to trigger.

[0092] The execution module includes a rule execution module and a trigger execution module.

[0093] The rule execution module is used to execute the message passed by the trigger as an input parameter, and execute each node module according to the configured rule chain and data flow conditions.

[0094] The rule statistics module is used to count the number of times different rule triggering methods are used within a certain time range, the line chart analysis of the maximum, minimum and average time consumption, the line chart analysis of success, failure and total number of times.

[0095] like Figure 2 As shown, the trigger execution module includes scheduled task monitoring, http interface monitoring, message queue monitoring, addition, deletion, modification and query monitoring, process approval monitoring, and form time monitoring; when triggered, the message is passed to the corresponding rule execution module through the message queue for execution, the rule execution module records the log and passes it to the rule statistics module, and the rule statistics module obtains the statistical chart.

[0096] An electronic device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor runs the computer program, the computer program is executed to implement the above method.

[0097] A computer-readable storage medium stores computer-readable instructions, which can be executed by a processor to implement the above method.

[0098] The present invention realizes low-code visual configuration, allowing non-technical personnel to easily implement business rules; it realizes microservice deployment, which is more convenient to expand, update faster, and manage more conveniently; and the present invention has diverse triggering methods, does not need to restart the service, and can be configured online according to personalized needs, realizing third-party docking, reducing costs and increasing efficiency.

[0099] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A method for using a distributed rule engine based on microservices, characterized in that: The following steps are involved: S1: Configure the logical execution node diagram of rule execution through the visual web interface, and then configure the triggering method of the rule; S2: After the corresponding execution node configuration is completed, the trigger triggers the instruction and executes the rule according to the received instruction and request parameters; S3: After the rule execution is completed, the rule execution log is saved.

2. The method for using a distributed rule engine based on microservices according to claim 1, characterized in that: In S1, the logical execution node diagram of rule execution is configured through the visual web interface, and then the specific content of the rule triggering method is configured as follows: Triggering methods include fixed time triggering, form time triggering, process triggering, data triggering, and MQ triggering; Fixed time trigger: set a cycle time, and execute the planned rules every time a cycle time is reached; Form time trigger: Select the date and time field in a table of a product application, and configure the trigger time point before or after the time value of all records in the table. The rule can be triggered every cycle. Process trigger: set the approval process data record change trigger and execute the configured rules; Data trigger: set a product application table to have data changes, and automatically execute the set rules; MQ trigger: When the external system is set to pass information to the rule engine platform through related operations or data changes, the platform will execute the corresponding rules based on the relevant information.

3. The method for using a distributed rule engine based on microservices according to claim 1, characterized in that: In S2, after the corresponding execution node configuration is completed, the trigger triggers the instruction, and the specific content of executing the rule according to the received instruction and request parameters is as follows: The publishing rules include: verifying the availability of the rule logic diagram. If the verification passes, the publishing is successful and a publishing version is generated; otherwise, the publishing fails and the reason for the failure of the rule publishing is prompted.

4. The method for using a distributed rule engine based on microservices according to claim 3, characterized in that: After the triggering conditions for executing the rule are met: the rule is executed according to the node configured in the rule logic diagram to determine whether it is the end node. If not, continue to execute; if so, the rule execution ends.

5. The method for using a distributed rule engine based on microservices according to claim 4, characterized in that: In the rules of the execution configuration node, the sub-rules support execution modes including sequential execution or concurrent execution; Sequential execution: The sub-rules have a certain order relationship with the subsequent nodes, so they are executed sequentially; Concurrent execution: If the node does not use the return data of the sub-rule, select concurrent execution.

6. A distributed rule engine based on microservices, which implements the method for using the distributed rule engine based on microservices according to claims 1-5, characterized in that: Including WEB visualization configuration module, execution module and rule statistics module; The WEB visualization configuration module includes the WEB visualization rule editing module and the WEB visualization trigger configuration module; The execution module includes a rule execution module and a trigger execution module.

7. The microservice-based distributed rule engine according to claim 6, characterized in that: The WEB visual rule editing module is used for flexible matching of multiple node modules, arranging and assembling them into rule chains from top to bottom, without restarting, and hot loading for trigger call execution; The WEB visualization trigger configuration module is used to configure various trigger conditions of the platform and which rule to trigger; The trigger execution module includes timed task monitoring, http interface monitoring, message queue monitoring, addition, deletion, modification and query monitoring, process approval monitoring, and form time monitoring; when triggered, the message is passed to the corresponding rule execution module through the message queue for execution; The rule execution module is used to execute the message passed by the trigger as an input parameter, and execute each node module according to the configured rule chain and data flow conditions; The rule statistics module is used to count the number of times different rule triggering methods are used within a certain time range, the line chart analysis of the maximum, minimum and average time consumption, and the line chart analysis of success, failure and total number of times.

8. An electronic device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method according to any one of claims 1 to 5.

9. A computer-readable storage medium, characterized in that: Computer-readable instructions are stored thereon, and the computer-readable instructions can be executed by a processor to implement the method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Method, system and server for realizing distributed service rules

    CN109656688A

  • Service-oriented customizable workflow engine algorithm

    CN110599119A

  • Component type low-code application configuration platform

    CN115617325A

  • Workflow engine method, system and equipment based on low-code platform and medium

    CN116069311A

  • Distributed flow processing method and device and distributed business flow engine

    CN116661978A