A method of using a microservice-based distributed rules engine and a rules engine

By using a microservice-based distributed rules engine with visual configuration and diverse triggering mechanisms, the problems of scalability and configuration complexity in software development are solved, enabling flexible and efficient software development and low-code visual configuration, thereby reducing R&D costs.

CN119536710BActive Publication Date: 2025-12-05JIANGSU HANBANGTANG TECHNOLOGY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Existing software development models suffer from problems such as difficulty in scaling up single-machine deployments, limited triggering methods, complex configurations, and high technical barriers, leading to increased R&D costs and project complexity.

Method used

It adopts a microservice-based distributed rule engine, which allows users to configure the rule execution node graph and triggering methods through a visual web interface. It supports diverse triggering mechanisms, as well as hot updates and dynamic expansion of rules.

Benefits of technology

It enables flexible and efficient software development, reduces customization costs, simplifies third-party integration, is suitable for non-technical personnel, and is easy to expand and update quickly.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119536710B_ABST
    Figure CN119536710B_ABST
Patent Text Reader

Abstract

The application discloses a kind of distributed rule engine use method and rule engine based on microservice, belong to rule engine technical field.The method of the application includes S1: the logical execution node graph of rule execution is configured by visual web interface, then the trigger mode of rule is configured;S2: after corresponding execution node configuration is completed, trigger triggers instruction, and executes rule according to received instruction and request parameter;S3: after rule execution is completed, the execution log of rule is saved.The application realizes low code visual configuration, so that non-technical personnel can easily realize business rule;Realize microservice deployment, it is more convenient to expand, update speed is fast, it is more convenient to manage;And the application trigger mode diversity, without restarting service, according to individualized demand online configuration, realize third party interface, reduce cost and increase efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of rule engines, and particularly relates to a distributed rule engine using method based on microservices and a rule engine. BACKGROUND

[0002] With the intensification of market competition and the diversification of customer demand, software development projects often need a lot of customized development to meet specific business needs. Such customized development not only consumes time and effort, but also increases the complexity of the project and the difficulty of later maintenance, thereby significantly increasing the R&D cost.

[0003] In the software development process, it is often necessary to interface with third-party systems or services. These third-party systems may have different data formats, interface protocols and business logic, making the interfacing work complex and tedious. The traditional software development mode often needs to develop an interface for each third-party system, which not only increases the development workload, but also prolongs the project cycle, further increasing the R&D cost.

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

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

[0006] 2. Single triggering mode, not supporting rule hot update and sub-rule;

[0007] 3. Complex configuration, high technical threshold, ordinary non-technical users are difficult to start. SUMMARY

[0008] In view of the deficiencies of the prior art, the application provides a distributed rule engine using method based on microservices and a rule engine, which can dynamically expand through visual rule management configuration, more efficiently handle complex business rules, simplify third-party interfacing rules, and reduce the customization cost of software development; and provides a more flexible, efficient and economical software development solution for enterprises.

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

[0010] A distributed rule engine using method based on microservices, comprising the following steps:

[0011] S1: configuring a logical execution node graph of rule execution through a visual web interface, and then configuring a triggering mode of the rule;

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

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

[0014] As preferred, in S1, the logical execution node graph 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:

[0015] The triggering mode includes fixed time triggering, form time triggering, process triggering, data triggering, and MQ triggering.

[0016] Fixed time triggering: set a cycle time, and execute the planned rule once every cycle time.

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

[0018] Process triggering: set the approval process data record change triggering, and execute the configured rule.

[0019] Data triggering: set a product application table to have data changes, and automatically execute the set rule.

[0020] MQ triggering: set an external system to transmit information to the rule engine platform through relevant operations or data changes, and the platform executes the corresponding rule according to the relevant information.

[0021] As preferred, in S2, after the corresponding execution node configuration is completed, the trigger triggers the instruction, and the specific content of the rule is executed according to the received instruction and request parameter as:

[0022] Publishing the rule includes verifying the availability of the rule logic graph. If the verification is passed, the publishing is successful, and a publishing version is generated. Otherwise, the rule publishing fails, and the reason for the failure is prompted.

[0023] As preferred, after the triggering condition of the rule is met: execute the rule according to the node configuration of the rule logic graph, and determine whether it is an ending node. If not, continue to execute; if yes, the rule execution is completed.

[0024] As preferred, in the rule executed by the configuration node, the execution mode supported by the sub-rule includes sequential execution or concurrent execution.

[0025] Sequential execution: the sub-rule has a certain order relationship with the subsequent node, and the sequential execution is selected.

[0026] Concurrent execution: the subsequent node does not use the return data of the sub-rule, and the concurrent execution is selected.

[0027] As preferred, the WEB visualization configuration module, the execution module and the rule statistics module are included;

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

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

[0030] As preferred, the WEB visualization rule editing module is used for flexible collocation of various node modules, and is arranged from top to bottom to form a rule chain, which is called and executed by the trigger after hot loading without restarting.

[0031] The WEB visualization trigger configuration module is used for configuring various trigger conditions and which rule is triggered.

[0032] The trigger execution module includes timing task listening, http interface listening, message queue listening, add, delete, modify and query listening, process approval listening and form time listening; when triggered, the message is transmitted to the corresponding rule execution module for execution through the message queue.

[0033] The rule execution module is used for executing the message transmitted by the trigger as an input parameter, executing various node modules according to the configured rule chain and data flow condition.

[0034] The rule statistics module is used for statistical analysis of the number of times of different trigger modes, maximum, minimum and average time consumption, success and failure and total number of times in a certain time range.

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

[0036] A computer readable storage medium has computer readable instructions stored thereon, and the computer readable instructions can be executed by a processor to implement the above method.

[0037] Advantages: compared with the prior art, the present application has the following advantages:

[0038] (1) The present application realizes micro-service deployment, is more convenient to expand, has fast update speed and is more convenient to manage.

[0039] (2) The present application realizes low-code visual configuration, so that non-technical personnel can easily realize business rules.

[0040] (3) The trigger mode diversity of the present application supports data trigger, timing trigger, database field time data trigger, HTTP trigger, MQ message queue trigger or flowable rule engine trigger, without restarting the service, according to the online configuration of individual needs, realizing the third party docking, reducing cost and increasing efficiency. BRIEF DESCRIPTION OF DRAWINGS

[0041] Figure 1 is a flowchart of the method for using the microservice-based distributed rule engine of the present application.

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

[0043] Figure 3 is a data flow diagram of the microservice-based distributed rule engine of the present application. DETAILED DESCRIPTION

[0044] The present application will be further illustrated below in combination with specific embodiments, which are implemented on the premise of the technical scheme of the present application, and it should be understood that these embodiments are only used to illustrate the present application and not to limit the scope of the present application.

[0045] The microservice-based distributed rule engine is a software system capable of automatically executing decisions according to predefined business rules. By using the rule engine, developers can separate business logic from program code and instead use a set of rules that are easy to understand and modify to control the behavior of the software. This approach not only improves the flexibility and maintainability of the software, but also reduces the development cost caused by business changes.

[0046] As shown in Figure 1 The method for using the microservice-based distributed rule engine provided by the present embodiment includes the following steps:

[0047] S1: Configure the logical execution node graph of rule execution through a visual web interface, and then configure the trigger mode of the rule;

[0048] The node includes 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 queue, sub-rule, field calculation, conditional branching, loop, association, convergence and custom script.

[0049] Data addition, deletion, modification and query node: A business table in a database can be selected for addition, deletion, modification and query operations.

[0050] Message notification node: Mail, message notification, SMS, Dingding and other methods can be set, and the message notification module is called through microservices to notify the corresponding user.

[0051] Internal service node: All microservices in the configurable call registration center.

[0052] External service node: External interface service that can be configured to call the HTTP protocol.

[0053] Cache node: Configurable to read or write data to Redis (Remote Dictionary Server).

[0054] Message queue node: Configurable to send data to a specified exchange or message queue.

[0055] Sub-rule node: Configurable to reuse existing rules, simplifying configuration.

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

[0057] Conditional branching node: Configurable to follow different rule chains when data meets different conditions.

[0058] Loop node: Configurable to iterate, fixed loop, or conditional loop, with loop body node configuration similar to sub-rules.

[0059] Association node: Re-aggregates two dataset objects into a new dataset based on association fields and connection methods.

[0060] Aggregation node: Filters and aggregates data from work tables or upstream dataset nodes.

[0061] For example: record count, sum, average, maximum, minimum, etc.

[0062] Custom node: Configurable groovy, java, and js scripts that do not require restarts and are hot-loaded for immediate effect.

[0063] Trigger methods include one or more of the following: new, modified, deleted data trigger, fixed period trigger, database field time data trigger, HTTP trigger, MQ (Message Queue) message queue trigger, or flowable (an open-source business process management (BPMS) platform) rule engine trigger.

[0064] Fixed time (period) trigger: A cycle period time can be set (e.g., every Monday at 9 am), and the planned rule can be executed once every time the period time is reached.

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

[0066] Form time trigger: the date and time field in the form table of a product application can be selected, and the trigger time point is configured before or after the time value of all records in the table, and the rule can be triggered every period.

[0067] For example, the birth date of each employee is recorded in the employee table, and the rule of sending a short message to the employee to wish a happy birthday is triggered at 8 am on the day of the employee's birthday.

[0068] Process trigger: the change of the approval process data record trigger can be set, and the configured rule is executed.

[0069] For example, after the warehouse order audit node agrees, the rule of automatically increasing the product inventory quantity is triggered.

[0070] Data trigger: the data change of a product application table can be set to automatically execute the set rule.

[0071] For example, the addition of data in the employee table triggers the rule of updating the address book and sending an email with the latest address book to all old employees.

[0072] MQ trigger: the external system can pass information to the rule engine platform through related operations or data changes, and the platform executes the corresponding rule according to the related information.

[0073] For example, after adding a new order in the CRM system and confirming it, a rule is triggered to synchronize a delivery application process in the inventory management system.

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

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

[0076] After the trigger condition of the execution rule is met, the following steps are included: executing the rule according to the node configuration of the rule logic diagram, judging whether it is an ending node, if not, continue to execute; if yes, the rule execution ends.

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

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

[0079] For example, the data returned by the child rule is used by the next node to perform the next action, and the execution of the subsequent rule node is performed in sequence after the execution of the child rule is completed.

[0080] Concurrent execution: the subsequent node does not use the return data of the child rule, and concurrent execution is selected to improve the execution efficiency of the rule.

[0081] For example, the scene of the child rule such as recording log, message notification, etc.

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

[0083] The method for using the micro-service-based distributed rule engine provided in the embodiments of the present application is illustrated below. For example, in the following scenario: when "device inspection", the information of the device with fault and the fault information are synchronized to "device maintenance application". Specifically:

[0084] Step 1: add a rule named "device inspection" through a visual web interface;

[0085] Step 2: add a new data node and name it "new maintenance application", set the table to be the device maintenance application table, and assign the fields to be 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 trigger for data trigger, select the table device inspection, and trigger when new data is added and the device status is equal to fault, and set the binding "device inspection" rule.

[0088] As shown in Figure 2 The micro-service-based distributed rule engine provided in the embodiments includes a WEB visual configuration module, an execution module, and a rule statistics module.

[0089] The WEB visual configuration module includes a WEB visual rule editing module and a WEB visual trigger configuration module.

[0090] The WEB visual rule editing module is used to arrange and assemble the rule chain from top to bottom based on the flexible collocation of various node modules, without restarting, and the rule chain is called and executed by the trigger after hot loading.

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

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

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

[0094] The rule statistics module is used for statistical analysis of the number of times of different triggering modes, the maximum, minimum and average time consumption, the success and failure and the total number of times in a certain time range.

[0095] As shown in Figure 2 The trigger execution module includes timing task listening, http interface listening, message queue listening, adding, deleting, modifying and inquiring listening, process approval listening and form time listening; when the trigger is triggered, the message is transmitted to the corresponding rule execution module for execution through the message queue, the rule execution module records the log and transmits 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 on the memory and executable on the processor, and the processor executes the computer program to implement the above method.

[0097] A computer readable storage medium has computer readable instructions stored thereon, and the computer readable instructions can be executed by a processor to implement the above method.

[0098] The present application realizes low-code visual configuration, so that non-technical personnel can easily realize business rules; realizes micro-service deployment, which is more convenient to expand, faster to update and more convenient to manage; and the present application has various triggering modes, does not need to restart the service, can be configured online according to individual needs, realizes third-party connection, reduces cost and increases efficiency.

[0099] The above only describes the preferred embodiments of the present application, and it should be pointed out that for ordinary skilled persons in the technical field, some improvements and refinements can be made without departing from the principles of the present application, and these improvements and refinements should also be regarded as the protection scope of the present application.

Claims

1. A method for using a microservice-based distributed rule engine, characterized in that: Comprise the following steps: S1: configure the logical execution node graph of rule execution through the visual web interface, and then configure the triggering mode of the rule; The triggering mode includes fixed time triggering, form time triggering, process triggering, data triggering, and MQ triggering; Fixed time triggering: set a cycle time, and execute the planned rule once every cycle time; Form time triggering: select a date and time field in the table of a certain product application, configure the time point before or after the time value of all records in the table, and trigger the rule every cycle; Process triggering: set the approval process data record change trigger to execute the configured rule; Data triggering: set a product application table to have data changes, and automatically execute the set rule; MQ triggering: set the external system to pass information to the rule engine platform through relevant operations or data changes, and the platform executes the corresponding rule according to the relevant information; The nodes include data addition, deletion, modification and query, message notification, calling external or internal services, operating redis cache, sending mq message queue, sub-rule, field calculation, condition branching, loop, association, aggregation and custom script; Data addition, deletion, modification and query node: select a database business table to add, delete, modify and query; Message notification node: set up email, message notification, SMS, Dingding, and notify the corresponding user through the microservice call message notification module; Internal service node: configure to call all microservices in the registration center; External service node: configure to call external interface services through the http protocol; Cache node: configure to read or write data to redis; Message queue node: configure to send data to a specified exchange or message queue; Sub-rule node: configure an existing rule to achieve rule reuse and simplify configuration; Field calculation node: the calculation result is assigned to other application tables or used as a flow condition; Condition branching node: different rule chains can be configured when the data meets different conditions; Loop node: configure iterative loop, fixed loop and conditional loop, and loop body node sub-rule; Association node: re-aggregate two data set objects into a new data set according to the association field and connection method; Aggregation node: filter and aggregate the data that meets the condition from the work table or upstream data set node; Custom node: configure groovy and java and js scripts without restarting; 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 parameter; S3: After the rule execution is completed, save the rule execution log; The microservice-based distributed rule engine includes a WEB visual configuration module, an execution module and a rule statistics module; The WEB visual configuration module includes a WEB visual rule editing module and a WEB visual trigger configuration module; The WEB visual rule editing module is used for flexible collocation of various node modules, and arranges and assembles from top to bottom into a rule chain without restarting, which is called and executed by the trigger after hot loading; The WEB visualization trigger configuration module is configured to configure a plurality of triggering conditions and which rule to trigger; The execution module includes a rule execution module and a trigger execution module; The trigger execution module includes a timing task listener, an HTTP interface listener, a message queue listener, an add, delete, modify and query listener, a process approval listener, and a form time listener; when triggered, the message is transmitted to the corresponding rule execution module for execution through the message queue; The rule execution module is configured to execute the message transmitted by the trigger as an input parameter, execute each node module according to the data flow condition according to the configured rule chain, and execute the message transmitted by the trigger as an input parameter. The rule statistics module is configured to analyze the line graph of the number of times, the maximum, the minimum and the average time consumption of the rule in a certain time range, the line graph of the success, the failure and the total number of times. The rule execution module records logs and transmits them to the rule statistics module, and the rule statistics module obtains a statistical chart.

2. The microservice-based distributed rules engine usage method according to claim 1, characterized in that: In S2, after the corresponding execution node configuration is completed, the trigger triggers an instruction, and the specific content of the rule is executed according to the received instruction and request parameter. The rule publishing includes: verifying the availability of the rule logic diagram, if the verification is passed, the publishing is successful, and a publishing version is generated; otherwise, the rule publishing fails, and a reason for the rule publishing failure is prompted.

3. The microservice-based distributed rules engine usage method of claim 2, wherein: After the trigger condition of the execution rule is met: the rule is executed according to the node configuration of the rule logic diagram, it is judged whether it is an ending node, if not, the execution is continued; if yes, the rule execution is ended.

4. The microservice-based distributed rules engine usage method of claim 3, wherein: In the execution of the rule of the configuration node, the execution mode supported by the sub-rule includes sequential execution or concurrent execution. Sequential execution: the sub-rule has a certain order relationship with the subsequent node, and the sequential execution is selected. Concurrent execution: the subsequent node does not use the return data of the sub-rule, and the concurrent execution is selected.

5. An electronic device comprising: A memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that: when the processor executes the computer program, the method as claimed in any one of claims 1 to 4 is implemented.

6. A computer-readable storage medium, characterized in that: A computer readable instruction is stored thereon, and the computer readable instruction can be executed by a processor to implement the method as claimed in any one of claims 1 to 4.

Citation Information

Patent Citations

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

    CN116069311A