Event stream design method and system based on rule engine and rule engine

The event flow design method and system based on a rule engine decouples business from code, allowing non-developers to adjust rule nodes visually, reducing maintenance complexity and costs while ensuring efficient business implementation.

CN119201083APending Publication Date: 2024-12-27广域铭岛数字科技有限公司 +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411301386.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-18
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

Existing technologies for implementing business process rules require tight coupling between business and code, necessitating professional developers for maintenance, leading to high development costs and long cycles, and impacting business implementation progress.

Method used

An event flow design method and system based on a rule engine that includes a rule editor interface with various business logic rule nodes, allowing non-developers to adjust rule nodes and connections based on business logic changes, using a visual development approach to separate business from code.

Benefits of technology

This method reduces maintenance difficulty, lowers development costs, and shortens cycles by enabling business personnel to modify rule engines without developer intervention, ensuring efficient business implementation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119201083A_ABST
    Figure CN119201083A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computers, and discloses an event flow design method and system based on a rule engine and the rule engine. Then selecting a plurality of business logic rule nodes as target rule nodes in the rule editor interface according to business execution logic of a to-be-created business, and creating connection lines among the target rule nodes according to a business process proceeding direction of the business execution logic; and configuring a service rule for each target rule node based on the service execution logic to obtain a service rule engine of the to-be-created service, when the service execution logic changes, adjusting the target rule nodes according to the changed service execution logic, and then adjusting a connection line between the adjusted target rule nodes to obtain a service rule engine of the to-be-created service. And the new business rule engine is obtained, so that the business and the code are not strongly coupled any more, the maintenance difficulty of the business project is reduced, the development cost is reduced, and the development period is shortened.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to an event stream design method, system and rule engine based on a rule engine. Background Art

[0002] In related technologies, the implementation of business process rules is often implemented using if else code or strategy mode, but these methods require new if else code or strategy to be implemented when facing rule changes. However, this method will make the business and code tightly coupled, making the maintenance of the entire business project more difficult. At the same time, the above implementation method requires professional developers to implement it, resulting in high development costs and long cycles, which may affect the implementation progress of the business. Summary of the invention

[0003] In order to provide a basic understanding of some aspects of the disclosed embodiments, a brief summary is given below. The summary is not an extensive review, nor is it intended to identify key / critical components or delineate the scope of protection of these embodiments, but rather serves as a prelude to the detailed description that follows.

[0004] In view of the shortcomings of the prior art mentioned above, the present invention discloses an event flow design method, system and rule engine based on a rule engine to solve the technical problems that in the implementation of business process rules in related technologies, business and code are strongly coupled, resulting in high difficulty in project maintenance, requiring professional personnel to implement, high development costs, long cycles, and may affect the progress of business implementation.

[0005] The embodiment of the present invention discloses an event flow design method based on a rule engine, and the event flow design method based on the rule engine includes: displaying a rule editor interface, the rule editor interface includes multiple types of business logic rule nodes, wherein each type corresponds to multiple business logic rule nodes; selecting multiple business logic rule nodes as target rule nodes in the rule editing interface according to the business execution logic of the business to be created; creating connections between the target rule nodes based on the business process direction of the business execution logic; configuring business rules for each of the target rule nodes based on the business execution logic to complete the construction of the business rule engine for the business to be created; if the business execution logic of the business to be created changes, adjusting the target rule nodes according to the changed business execution logic, and adjusting the connections between the adjusted target rule nodes to complete the construction of the business rule engine for the changed business to be created.

[0006] In one embodiment of the present invention, the target rule nodes are adjusted according to the changed business execution logic, and the connections between the adjusted target rule nodes are adjusted, including: comparing the changed business execution logic with the business execution logic before the change to determine the logical differences; deleting and / or adding the target rule nodes based on the logical differences to adjust the target rule nodes; creating connections between the adjusted target rule nodes according to the business process direction of the changed business execution logic to adjust the connections between the adjusted target rule nodes; configuring new business rules for each of the adjusted target rule nodes based on the business execution logic.

[0007] In one embodiment of the present invention, the types of the business logic rule nodes include general types, functional types, network types and database types, wherein: the business logic rule nodes of the general type include at least one of the following: a timing task node for timingly triggering a downstream node, a delay node for rate controlling node data, a routing node for determining a data transmission path, a listening completion node for monitoring the data processing execution completion status of a monitored node, a capture exception node for monitoring the abnormal status of a monitored node, and an annotation node for annotation; the business logic rule nodes of the functional type include at least one of the following: a function node, an event bus event processing node for subscribing to an event bus data stream and performing data processing, an attribute subscription node for subscribing to device reported data, an attribute query node for querying the latest reported value of a device point, a device instruction node for sending instructions to a device, a write device node for writing data into time series data, an event subscription node for subscribing to device events, and a message notification node; the business logic rule nodes of the network type include at least one of the following: a subscription node and a write node; the business logic rule nodes of the database type include at least one of the following: a write database node and an execution node.

[0008] In one embodiment of the present invention, after selecting multiple business logic rule nodes as target rule nodes in the rule editing interface according to the business execution logic of the business to be created, the method also includes: if the business logic rule nodes in the rule editing interface cannot meet the requirements of the business execution logic of the business to be created, creating a custom node according to the requirements of the business execution logic that cannot be met; and using the custom node as the target rule node.

[0009] In one embodiment of the present invention, when data is flowing between the target rule nodes in the business rule engine, the target rule node serving as the data sending end publishes the data to be circulated to the distributed event bus to store the data to be circulated in a preset memory space, and the target rule node serving as the data receiving end obtains the data to be circulated from the preset memory space.

[0010] In one embodiment of the present invention, the target rule node serving as a data receiving end obtains the data to be circulated from the preset memory space, including: the distributed event bus determines the target rule node corresponding to the data to be circulated based on a preset data subscription mapping relationship, and the preset data subscription mapping relationship is used to indicate the subscription mapping relationship between the data to be circulated and the target rule node; and pushes the data to be circulated to the target rule node, so that the target rule node reads the data to be circulated from the preset memory space.

[0011] In one embodiment of the present invention, if the target rule node serving as a data receiving end processes rules for the data to be circulated less quickly than the target rule node serving as a data sending end publishes the data to be circulated to the distributed event bus, the target rule node serving as a data sending end is controlled to reduce the data publishing speed.

[0012] In one embodiment of the present invention, the target rule node serving as the data sending end is controlled to reduce the data publishing speed, including: storing excess data to be circulated in a first temporary queue, and when the remaining data storage space of the first temporary queue is exhausted, discarding the data to be circulated first stored in the first temporary queue.

[0013] In one embodiment of the present invention, the target rule node serving as the data sending end is controlled to reduce the data publishing speed, including: storing excess data to be circulated in a first temporary queue, and when the remaining data storage space of the first temporary queue is exhausted, sending the data to be circulated first stored in the first temporary queue to the first Kafka message queue, and after the rule processing speed is greater than the data publishing speed, pushing the excess data to be circulated in the first Kafka message queue to the target rule node serving as the data receiving end, so as to perform rule processing on the excess data to be circulated through the business rules corresponding to the target rule node serving as the data receiving end.

[0014] The embodiment of the present invention discloses an event flow design system based on a rule engine, and the event flow design system based on the rule engine includes: a rule editor interface, the rule editor interface includes multiple types of business logic rule nodes, wherein each type corresponds to multiple business logic rule nodes; a node selection module, which is used to select multiple business logic rule nodes as target rule nodes in the rule editing interface according to the business execution logic of the business to be created; a connection creation module, which is used to create connections between target rule nodes based on the business process direction of the business execution logic; a rule configuration module, which is used to configure business rules for each of the target rule nodes based on the business execution logic to complete the construction of the business rule engine for the business to be created; an adjustment module, which is used to adjust the target rule nodes according to the changed business execution logic if the business execution logic of the business to be created changes, and adjust the connections between the adjusted target rule nodes to complete the construction of the business rule engine for the changed business to be created.

[0015] An embodiment of the present invention discloses a rule engine, which is designed based on the event stream design method based on the rule engine as described in any of the above embodiments. The rule engine includes a rule node, a rule engine core and multiple business rules. The rule engine core includes a rule parser, a task scheduler and a rule executor, wherein the rule node includes multiple rule sub-nodes, which are used to determine the target rule sub-node according to the data to be circulated provided by the data source, and determine at least one target business rule from multiple business rules for the data to be circulated through the target rule sub-node; the rule parser is used to parse the business rules into an executable rule model; the task scheduler is used to parse the executable rule model into a task to be executed and schedule it to a corresponding task executor, the task executor is used to execute and maintain tasks, and the task executor includes one or more rule executors; the rule executor is used to execute the task to be executed.

[0016] An embodiment of the present invention discloses an electronic device, including: a processor and a memory; the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the electronic device executes the above method.

[0017] Beneficial effects of the present invention:

[0018] By displaying a rule editor interface including multiple types of business logic rule nodes, and then selecting multiple business logic rule nodes as target rule nodes in the rule editor interface according to the business execution logic of the business to be created, creating connections between each target rule node according to the business process direction of the business execution logic, and configuring business rules for each target rule node based on the business execution logic, the business rule engine for the business to be created is obtained. When the business execution logic changes, the target rule node is adjusted according to the changed business execution logic, and then the connections between the adjusted target rule nodes are adjusted to obtain the changed business rule engine for the business to be created. Through such an event flow design method, the business and the code are no longer strongly coupled, which reduces the difficulty of maintaining business projects. The visual development method enables business personnel other than developers to modify the rule engine based on changes in the business execution logic, and then implement the changed business execution logic through the modified rule engine, which reduces development costs, shortens the development cycle, and avoids the impact on the implementation progress of the business. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 It is a flowchart of an event flow design method based on a rule engine in an embodiment of the present invention;

[0020] Figure 2 is a schematic diagram of a process editor interface in an embodiment of the present invention;

[0021] Figure 3 is a schematic diagram of a business logic rule node in an embodiment of the present invention;

[0022] Figure 4 is a schematic diagram of editing data source node attributes in an embodiment of the present invention;

[0023] Figure 5 is a schematic diagram of editing routing node attributes in an embodiment of the present invention;

[0024] Figure 6 is a schematic diagram of editing function node attributes in an embodiment of the present invention;

[0025] Figure 7 is a schematic diagram of editing and writing attributes of a downstream system in an embodiment of the present invention;

[0026] Figure 8 is a schematic diagram of a business process in an embodiment of the present invention;

[0027] Fig. 9 yes Figure 8 A schematic diagram of the logic behind the business process shown;

[0028] Fig.10 yes Figure 8 A schematic diagram of data flow of the business process shown;

[0029] Fig.11 It is a schematic diagram of file IO;

[0030] Fig.12 is a schematic diagram of another data flow provided by an embodiment of the present invention;

[0031] Fig.13 It is a schematic diagram of an implementation framework in an embodiment of the present invention;

[0032] Fig.14 It is a structural diagram of an event stream design system based on a rule engine in an embodiment of the present invention;

[0033] Fig.15 is a schematic diagram of the structure of a rule engine in an embodiment of the present invention;

[0034] Fig.16 It is a schematic diagram of the structure of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION

[0035] The following describes the embodiments of the present invention through specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and sub-samples in the embodiments can be combined with each other without conflict.

[0036] It should be noted that the illustrations provided in the following embodiments are only used to illustrate the basic concept of the present invention in a schematic manner. Therefore, the drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the form, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.

[0037] In the following description, numerous details are discussed to provide a more thorough explanation of the embodiments of the present invention. However, it is obvious to those skilled in the art that the embodiments of the present invention can be implemented without these specific details. In other embodiments, well-known structures and devices are shown in the form of block diagrams rather than in detail to avoid making the embodiments of the present invention difficult to understand.

[0038] The terms "first", "second", etc. in the specification and claims of the embodiments of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchanged where appropriate, so as to describe the embodiments of the embodiments of the present disclosure described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions.

[0039] Unless otherwise stated, the term "plurality" means two or more.

[0040] In the embodiment of the present disclosure, the character " / " indicates that the preceding and following objects are in an "or" relationship. For example, A / B indicates: A or B.

[0041] The term "and / or" is a description of the association relationship between objects, indicating that three relationships can exist. For example, A and / or B means: A or B, or, A and B.

[0042] In order to facilitate understanding of the technical solutions of the embodiments of the present application, a brief introduction to the related technologies of the present application is first given as follows.

[0043] IOT (Internet of things) refers to the real-time collection of any object or process that needs to be monitored, connected, and interacted through various devices and technologies such as information sensors, radio frequency identification technology, global positioning system, infrared sensors, laser scanners, etc., and the collection of various required information such as sound, light, heat, electricity, mechanics, chemistry, biology, location, etc., and the realization of ubiquitous connection between objects and objects, objects and people through various possible network access, and the realization of intelligent perception, identification and management of objects and processes. The Internet of Things is an information carrier based on the Internet, traditional telecommunications networks, etc. It allows all ordinary physical objects that can be independently addressed to form an interconnected network.

[0044] Reactor3, a mature non-blocking responsive programming framework, has the characteristics of high performance and high throughput, high resource utilization, strong scalability, and fast response.

[0045] BackPressure mechanism: This mechanism ensures that each node can control the speed of receiving data according to its own consumption capacity. When the node consumption speed cannot keep up with the production speed, the upstream node will store the excess data in the queue (if the queue is full, it will be discarded). This ensures the stability of the engine operation as a whole and prevents failures due to peak data.

[0046] The code is interface-oriented. The interface-oriented code design can be convenient for customizing rule nodes when the existing nodes cannot meet the business scenarios. If necessary, you can even customize the scheduling strategy.

[0047] Event Bus is an implementation of the publish-subscribe model. It is a centralized event processing mechanism that allows different components to communicate with each other without relying on each other, achieving a decoupling purpose.

[0048] Combination Figure 1 As shown, Figure 1 FIG. 1 is a flow chart of an event flow design method based on a rule engine in an embodiment of the present invention. Figure 1 As shown, the embodiment of the present disclosure provides an event flow design method based on a rule engine, including:

[0049] Step S110, displaying the rule editor interface.

[0050] The rule editor interface includes multiple types of business logic rule nodes, wherein each type corresponds to multiple business logic rule nodes.

[0051] It can be understood that the rule editor interface can provide multiple types of business logic rule nodes for users to choose from, so that users only need to select appropriate business logic rule nodes according to their needs, without having to make adjustments at the code level, making business implementation more convenient.

[0052] In one embodiment, the types of business logic rule nodes include general type, function type, network type and database type, wherein:

[0053] The general type of business logic rule node includes at least one of the following: a timing task node for timingly triggering a downstream node, a delay node for rate control of node data, a routing node for determining a data transmission path, a listening completion node for monitoring the data processing execution completion status of a monitored node, a capture exception node for monitoring the abnormal status of a monitored node, and an annotation node for annotation;

[0054] The business logic rule node of the function type includes at least one of the following: a function node, an event bus event processing node for subscribing to an event bus data stream and performing data processing, an attribute subscription node for subscribing to device reported data, an attribute query node for querying the latest reported value of a device point, a device instruction node for sending instructions to a device, a write device node for writing data into time series data, an event subscription node for subscribing to device events, and a message notification node;

[0055] The network type business logic rule node includes at least one of the following: a subscription node and a write node;

[0056] The database type business logic rule node includes at least one of the following: a write database node and an execution node.

[0057] See also Figure 2 , Figure 2 is a schematic diagram of a process editor interface in an embodiment of the present invention, such as Figure 2 As shown in the figure, in the right screen (test page) of this interface, you can see many nodes (business logic rule nodes), which are connected by lines. The business logic is abstracted into business logic rule nodes, and the "connection" indicates the direction of the business process. Different business scenarios are realized through the combination of business logic rule nodes. This way of presentation can intuitively understand what the business is and how the business is conducted. Even a business person who does not understand development can play the business well. When the business changes, you only need to change the business logic rule nodes, the rules of the business logic rule nodes, and the direction of the connection lines.

[0058] See also Figure 3 , Figure 3 It is a schematic diagram of a business logic rule node in an embodiment of the present invention. It can be understood that Figure 3 for Figure 2 The expanded schematic diagram of the business logic rule node provided on the left side of the figure should be noted that the following is only an example, and those skilled in the art can add or reduce it as needed. Figure 3 As shown, taking the application in IIOT (Industrial Internet of Things) usage scenario as an example, the business logic rule nodes include general, functional, network and database types, and the specific node examples corresponding to each type are as follows.

[0059] For general class nodes, the following nodes can be included:

[0060] Scheduled task node: triggers downstream nodes on a scheduled basis and defines the execution plan through corn expressions.

[0061] Delay node: controls the rate of data passing through the node.

[0062] Routing node: triggers corresponding rules through messages to determine the data transmission route.

[0063] Listen to the completion node: listen to a node and trigger it when it completes processing the data.

[0064] Capture abnormal nodes: monitor a certain node and trigger it when an abnormality occurs in the node.

[0065] Annotation node: Annotation adds human annotations, often used by business personnel to take notes.

[0066] Functional nodes may include the following nodes:

[0067] Function node: Use scripts to process data. For example, the script uses the jsr223 engine and the js language is used by default.

[0068] ReactorQL node (event bus event processing node): This node is customized for the IIOT platform and is used to subscribe to the event bus data stream and process data.

[0069] Attribute subscription node: IIoT platform customized node, used to subscribe to the data reported by the device to the IoT platform.

[0070] Attribute query node: IIoT platform customized node, used to query the latest reported value of the device point.

[0071] Device instruction node: IIoT platform customized node, used to send instructions to the device, such as attribute reading, attribute updating, and function execution.

[0072] Write to IOT device node (write to device node): IIoT platform customized node. Sometimes the device point data comes from MQ. At this time, this node is required to write the data into the platform sequence.

[0073] Event subscription node: IIoT platform customized node, used to subscribe to device events, such as attribute events, device online and offline events, etc.

[0074] Message notification node: used to send message notifications, such as text messages, emails, etc.

[0075] For network nodes, the following nodes can be included:

[0076] Subscribe to Kafka node (a type of subscription node): subscribe to data from the Kafka service.

[0077] Write Kafka node (a type of write node): writes data to Kafka.

[0078] Subscribe to RabbitMq node (a type of subscription node): subscribe to data from the RabbitMq service.

[0079] Write to RabbitMq node (a type of write node): write data to the RabbitMq server.

[0080] Subscribe to MQTT node (a type of subscription node): IIoT platform customized node that obtains data from MQTT broker.

[0081] Write MQTT node (a type of write node): IIoT platform customized node that writes data into MQTT.

[0082] Database nodes may include the following nodes:

[0083] Write to database node: write data to the specified database.

[0084] Sql execution node (execution node): supports CRUD (add, delete, modify and query) of database data in SQL mode.

[0085] Step S120 , selecting multiple business logic rule nodes as target rule nodes in the rule editing interface according to the business execution logic of the business to be created.

[0086] Continue to see Figure 2 , you can select the target rule node from the nodes on the left and drag it to the test page (business process drawing area) on the right. The node in the business process drawing area is the target rule node.

[0087] In one embodiment, after selecting multiple business logic rule nodes as target rule nodes in the rule editing interface according to the business execution logic of the business to be created, the method also includes: if the business logic rule nodes in the rule editing interface cannot meet the requirements of the business execution logic of the business to be created, creating a custom node according to the requirements of the business execution logic that cannot be met; and using the custom node as the target rule node.

[0088] Those skilled in the art can reasonably select existing business logic rule nodes in the process editor interface according to business needs. Of course, sometimes considering new requirements, nodes can be customized to meet business needs.

[0089] Step S130 , creating connections between target rule nodes based on the business process direction of the business execution logic.

[0090] This connection is to visualize the direction of the business process. Figure 2 For example, the connection between the device instruction node and the function node is the connection between the target rule nodes. A node can establish a connection with one or more nodes.

[0091] The connection may be automatically generated (pre-configured with connection relationships of some nodes), or may be adjusted by those skilled in the art as needed.

[0092] Step S140: configuring business rules for each target rule node based on the business execution logic to complete the construction of the business rule engine for the business to be created.

[0093] Business rules can be understood as rules corresponding to target rule nodes. A target rule node may correspond to one or more pre-configured business rules, which can be selected by technicians in the field as needed or configured by technicians in the field based on current business needs.

[0094] For example, by selecting a preset business process related node, a property editing box is triggered to display, and those skilled in the art can change or edit its properties, such as the node name, address, etc.

[0095] The implementation of this method can be achieved by introducing node red (browser-based process editor) technology, and the business process can be drawn by horizontal dragging, which makes the business process more intuitive and easier to understand.

[0096] Step S150, if the business execution logic of the business to be created changes, adjust the target rule nodes according to the changed business execution logic, and adjust the connections between the adjusted target rule nodes to complete the construction of the business rule engine for the changed business to be created.

[0097] In one embodiment, the target rule nodes are adjusted according to the changed business execution logic, and the connections between the adjusted target rule nodes are adjusted, including: comparing the changed business execution logic with the business execution logic before the change to determine the logical differences; deleting and / or adding the target rule nodes based on the logical differences to adjust the target rule nodes; creating connections between the adjusted target rule nodes according to the business process direction of the changed business execution logic to adjust the connections between the adjusted target rule nodes; configuring new business rules for each adjusted target rule node based on the business execution logic.

[0098] It may be necessary to add new target rule nodes, delete existing target rule nodes, or add some target rule nodes and delete some target rule nodes. Once the target rule nodes change, the connection may need to be adjusted accordingly. Of course, since it is inheriting the original business, generally speaking, not all target rule nodes will be deleted, and accordingly, not all connections may be modified.

[0099] In one embodiment, when data is flowing between target rule nodes in a business rule engine, the target rule node serving as the data sending end publishes the data to be circulated to the distributed event bus to store the data to be circulated in a preset memory space, and the target rule node serving as the data receiving end obtains the data to be circulated from the preset memory space.

[0100] Compared with the related technologies that rely on file IO, data can be transmitted directly through the event bus, which consumes less resources and takes relatively less time.

[0101] Continuing from the above embodiment, the target rule node as a data receiving end obtains the data to be circulated from the preset memory space, including: the distributed event bus determines the target rule node corresponding to the data to be circulated based on the preset data subscription mapping relationship, and the preset data subscription mapping relationship is used to indicate the subscription mapping relationship between the data to be circulated and the target rule node; and pushes the data to be circulated to the target rule node, so that the target rule node reads the data to be circulated from the preset memory space.

[0102] Continuing from the above embodiment, if the target rule node as the data receiving end processes rules for the data to be circulated less quickly than the target rule node as the data sending end publishes the data to be circulated to the distributed event bus, the target rule node as the data sending end is controlled to reduce the data publishing speed.

[0103] The downstream nodes process data slowly, while the upstream nodes provide too much data, which will lead to a large backlog of data and affect the effect of data processing. To this end, a backpressure mechanism can be introduced to enable the upstream nodes to adjust their production speed according to the consumption capacity of the downstream nodes to balance the pressure on the data consumption end.

[0104] In one embodiment, the target rule node as the data sending end is controlled to reduce the data publishing speed, including: storing the excess data to be circulated in the first temporary queue, and when the remaining data storage space of the first temporary queue is exhausted, discarding the data to be circulated first stored in the first temporary queue. The specific amount of the excess data to be circulated can be determined according to the rule processing speed and the data publishing speed, and then stored in the first temporary queue. Of course, the capacity of the first temporary queue is also limited. At this time, the data to be circulated that first enters the first temporary queue can be discarded according to the first-in-first-out principle to ensure that the most recent data can be stored in time. And, when the rule processing speed is greater than the data publishing speed, the data to be circulated in the first temporary queue is published on the event bus in sequence for downstream nodes to process it.

[0105] In another embodiment, the target rule node as the data sending end is controlled to reduce the data publishing speed, including: storing excess data to be circulated in a first temporary queue, and when the remaining data storage space of the first temporary queue is exhausted, sending the data to be circulated first stored in the first temporary queue to the first Kafka message queue, and after the rule processing speed is greater than the data publishing speed, pushing the excess data to be circulated in the first Kafka message queue to the target rule node as the data receiving end, so as to perform rule processing on the excess data to be circulated through the business rules corresponding to the target rule node as the data receiving end.

[0106] Different from the implementation of the previous embodiment, in the scheme of this embodiment, the data is not directly discarded, but the data discarded (discarded) in the previous embodiment is transferred to the first Kafka message queue and then waits for subsequent consumption. Of course, in this scheme, the data in the first Kafka message queue can be consumed first, and then the data in the first temporary queue can be consumed until all the data is consumed.

[0107] By introducing the back pressure mechanism in the above way, the program can still run stably when a large amount of data pours in, and failures such as OOM (Out Of Memory) will not occur.

[0108] In one embodiment, the method is implemented based on a non-blocking responsive programming framework in the code dimension. The program software corresponding to the method is implemented by a non-blocking responsive programming framework such as Reactor3. Netty framework is a good solution for the problem of massive device access and large file transfer. Netty adopts NIO-based multiplexing technology, and its Reactor thread model can process multiple IO events in one thread, greatly improving the network IO efficiency. By introducing Reactor3 responsive technology, Reactor3 is a mature non-blocking responsive programming framework, which has the characteristics of high performance, high throughput, high resource utilization, and fast response. Through the multiplexing principle of Netty, the number of threads and the number of context switches can be effectively reduced under high concurrency, thereby improving the program response speed. The conventional synchronous blocking programming method and the context switching of threads under multi-threading cause low throughput and slow response. And when facing massive business data, it is easy to cause data backlog, resulting in program OOM. In addition, Reactor3 has good support for back pressure. The method provided in the embodiment of the present invention reasonably uses this point when implementing the code, and adds a back pressure mechanism to each node. Therefore, when massive amounts of data pour in, the program can still run stably without causing failures such as OOM.

[0109] In one embodiment, the method adopts an "interface-oriented" design concept, all core functions are abstracted, and when the built-in interface does not meet business requirements, developers can customize rule nodes.

[0110] This method can be implemented based on Reactor3, which is a mature non-blocking responsive programming framework with high performance and high throughput, high resource utilization, strong scalability, and fast response. BackPressure mechanism can also be introduced, which can ensure that each node can control the speed of data reception according to its own consumption capacity. When the node consumption speed cannot keep up with the production speed, the upstream node will store the excess data in the queue (if the queue is full, it will be discarded), which ensures the stability of the engine operation as a whole and will not fail due to peak data. Code implementation is interface-oriented, and interface-oriented code design can facilitate custom rule nodes when existing nodes cannot meet business scenarios. If necessary, you can even customize the scheduling strategy. Based on the responsive event bus Eventbus, data between nodes flows through memory without opening IO, which greatly improves the processing speed.

[0111] The event flow design method based on the rule engine provided in the above embodiment displays a rule editor interface including multiple types of business logic rule nodes, and then selects multiple business logic rule nodes as target rule nodes in the rule editor interface according to the business execution logic of the business to be created, creates connections between the target rule nodes according to the business process direction of the business execution logic, and configures business rules for each target rule node based on the business execution logic to obtain the business rule engine for the business to be created. When the business execution logic changes, the target rule nodes are adjusted according to the changed business execution logic, and then the connections between the adjusted target rule nodes are adjusted to obtain the changed business rule engine for the business to be created. Through such an event flow design method, the business and the code are no longer strongly coupled, which reduces the maintenance difficulty of the business project. The visual development method enables business personnel other than developers to modify the rule engine based on the changes in the business execution logic, and then implement the changed business execution logic through the modified rule engine, which reduces the development cost, shortens the development cycle, and avoids the impact on the implementation progress of the business.

[0112] The following is an illustrative example of the event flow design method based on the rule engine and the visual business process formulation method provided in the above embodiment. Taking the consumption point increase scenario as an example, an example rule is as follows:

[0113] 1. Spend 100 yuan or more and get 10 points;

[0114] 2. 50 points will be given for purchases over 500 yuan;

[0115] 3. For purchases of RMB 1,000 or more, 100 points will be given;

[0116] 4.…

[0117] When implementing functions, the following examples are used in related technologies to implement the if else method:

[0118]

[0119] If the strategy mode is adopted, an exemplary implementation is as follows:

[0120]

[0121]

[0122] Although both methods can achieve the above scenarios, they are extra cumbersome when encountering rule changes, such as adjusting the points ratio or increasing the points level, and developers have to add new if else code or strategy implementation. On the other hand, doing so will make the business and code tightly coupled, and as the business continues to change, the entire project will become difficult to maintain. The most fatal thing is that when the business changes, the changes must be handed over to developers to implement, and the cost of code development may affect the normal implementation of the business.

[0123] It can be seen that if the technical solution of the relevant technology is adopted, the following problems exist:

[0124] 1) Strong coupling between business logic and code. The code is strongly coupled. Although "design patterns" can be used to reduce this coupling, the effect is often not good. For example, in the "strategy pattern", when the number of business rules increases, the number of implementation subclasses will gradually increase.

[0125] 2) When the business changes, developers are often entrusted with the responsibility. Sometimes, when the business changes, a quick response is expected, but the response speed is often constrained by the company's development and implementation process: business personnel put forward requirements -> product managers evaluate requirements -> architects conduct technical reviews -> developers develop -> testers test -> project deployment. When these tedious processes are completed, a week or two may have passed. At this point, the normal development of the business will be seriously affected.

[0126] 3) Rules are difficult to understand and business knowledge is difficult to concentrate. When business is strongly bound to code, another problem has to be faced, that is, business is difficult to understand. Imagine when a new person comes in, he has to navigate a complex ocean of code to get familiar with the business process. What's more frightening is, what if this new person is a business person who doesn't understand code?

[0127] Based on the above problems, the inventor hopes to propose a solution that can separate business from code, business from data, and get rid of coding (or reduce coding), so that the separated code is easier to understand. And the whole system can run efficiently and stably, that is, the aforementioned event flow design method based on rule engine.

[0128] Continue to refer Figure 2 and Figure 3 Based on the above consumption and points increasing scenario, you can choose "Subscribe to RabbitMq Node", "Routing Node", "Function Node", "Send RabbitMq Node", which are all business logic rule nodes (built-in nodes). An example implementation process is as follows:

[0129] 1) Define the data source. Select "Subscribe to RabbitMq Node". This is to consume the order data of RabbitMq. This node will create an MQTT client (a client for implementing MQTT protocol communication) to obtain order data by subscribing to / order. Figure 4 , Figure 4 Schematic diagram of editing data source node attributes in an embodiment of the present invention. Figure 4 As shown, the user can modify the properties, description, and appearance of the node. In the properties section, the node name, address, user name, password, virtual domain, and queue can be edited. Here, the node name takes "Subscription Consumption Order Data" as an example. Technical personnel in this field can also set other names. The address takes 127.0.0.0:5632 as an example, the user name and password take guest as an example, no virtual domain is set, and the queue is implemented in the form of order as an example.

[0130] 2) Define consumption rules. Select "routing node", which will determine the subsequent direction of the business based on the amount. Figure 5 , Figure 5 Schematic diagram of editing routing node attributes in an embodiment of the present invention. Figure 5 As shown, the edit routing node can also be modified from the attribute, description, and appearance dimensions. In the attribute dimension, the node name and attribute content can be edited. Here, the node name is consumption rule as an example, and the attribute is order amount. Then, for order amounts less than or equal to 100, it is routed to 1, for order amounts greater than 100 and less than or equal to 500, it is routed to 2, for order amounts greater than 500 and less than or equal to 1000, it is routed to 3, and in addition, order amounts greater than 1000 are all routed to 4.

[0131] 3) Define and add points node. Select "Function node". This node defines the business logic under the current consumption rules. Figure 6 , Figure 6 Schematic diagram of editing function node attributes in an embodiment of the present invention. Figure 6 As shown, the function node can be modified from the attributes, description, appearance and debugging dimensions. In the attribute dimension, the node name and the corresponding function can be edited. Here, the node name "Increase points when full 100" is taken as an example, and the corresponding function is edited.

[0132] 4) Write to downstream system. Select "Write to RabbitMq node". This node is responsible for writing business data to downstream system. Figure 7 , Figure 7 Schematic diagram of editing and writing properties of a downstream system in an embodiment of the present invention. Figure 7 As shown, the relevant attributes written into the downstream system can be edited from the attribute, description, and appearance dimensions. In the attribute dimension, the node name, address, user name, password, virtual domain, routingKey, exchange, and other dimensions can be edited.

[0133] See also Figure 8 , Figure 8 is a schematic diagram of a business process in an embodiment of the present invention, such as Figure 8 As shown, it starts with subscribing to consumption order data, then consumption rules, then providing integral nodes, and then writing into the downstream system. The entire process is visualized and easy for business personnel to understand and operate.

[0134] See also Fig. 9 , Fig. 9 yes Figure 8 A schematic diagram of the logic behind the business process shown, such as Fig. 9 As shown in the figure, in the node for subscribing to and consuming order data, this node acts as a RabbitMq client, subscribes to a RabbitMq broker, and obtains order data as the data source for the entire business process. In the consumption rule stage, it is equivalent to the if-else code in the related technology (traditional method), and different logics are executed according to different conditions. Here, the direction of subsequent business is determined according to the consumption quantity (consumption amount). In the stage of increasing points, it is equivalent to the code block after if, and the corresponding business logic is executed. In the stage of writing to the downstream system, the result data is sent to the downstream system.

[0135] See also Fig.10 , Fig.10 yes Figure 8 The schematic diagram of the data flow of the business process shown in Fig.10As shown, the initial data source MQ sends the data to be published (data, an example of data to be circulated) as the subscription consumption order data, which is published to the event bus (distributed event bus) through the back pressure mechanism (also called the pressure mechanism), and obtains the order data (unlimited quantity, Fig.10 The example is only in the figure), the consumption rule (routing node, an example of a business logic rule node) subscribes to the order data, executes logical judgment, determines the next route to obtain the routing message, publishes it to a specific Topic on the event bus via the back pressure mechanism, obtains the routing message, and then increases the points (function node, an example of a business logic rule node) to subscribe to the routing message, executes the corresponding points increase logic, obtains the result data, and publishes the result data to the event bus via the back pressure mechanism. The event bus obtains the result data and writes it to the downstream system to subscribe to the result data. When the result data is subscribed, it is sent to the result data source MQ. It should be noted that Fig.10 Both are marked as MQ, but it does not mean that the two must be the same database, but can be different databases, or different tables in the same database. The above-mentioned data to be published, result data, etc. are all examples of data to be circulated.

[0136] Obviously, this method makes it easier to understand the business process and make changes to the business easier.

[0137] When new data to be circulated is published on the event bus, it can be matched to the corresponding downstream node according to the preset data subscription mapping relationship, and then the data to be circulated can be published and pushed to the downstream node.

[0138] According to the data to be circulated, at least one consumption rule (an example of a business rule) is determined from multiple consumption rules as the target business rule, and the next step of routing is obtained to generate a routing message; the routing message is published to the target topic (specific Topic) on the event bus; the event bus determines the downstream node corresponding to the routing message based on the preset topic subscription mapping relationship of the business rule execution module, and pushes the routing message to the downstream node. The preset topic subscription mapping relationship is used to indicate the subscription mapping relationship between the topic and the downstream node; the downstream node executes the business rule based on the routing message to obtain the result data. The preset topic subscription mapping relationship can be obtained after all the business logic rule nodes participating in the method have subscribed to the topic on the event bus in advance. The preset topic subscription mapping relationship can be used to match which business logic rule nodes have subscribed to which topics.

[0139] There are multiple rules in the rule engine. You need to first determine which specific rule or rules the data to be published corresponds to, that is, determine the target business rule, and then know the next route, get the routing message, and publish the routing message to a specific Topic (target topic) on the event bus. Because different rules have different execution modules, then based on the subscription information of the business rule execution module, the routing message required by the business rule execution module is pushed to the corresponding business logic rule node to trigger it to execute the corresponding rule and obtain the result data.

[0140] In view of the problem that conventional rule engines use synchronous blocking programming methods and context switching of threads under multi-threading when processing business data, resulting in low throughput and slow response, Reactor3 responsive technology is introduced. Reactor3 is a mature non-blocking responsive programming framework with high performance, high throughput, high resource utilization, and fast response. Through the multiplexing principle of NETTY, the number of threads and the number of context switches can be effectively reduced under high concurrency, thereby improving the program response speed.

[0141] Reactor3 has good support for pressure (also known as back pressure). When implementing the code, we use this reasonably and add a pressure mechanism to each node. Therefore, when a large amount of data is poured in, the program can still run stably without failures such as OOM. The upstream node can adjust its production speed according to the consumption capacity of the downstream node. When there is excess capacity, the excess data will be placed in the queue. If the queue is full, the data will be discarded (or sent to Kafka for subsequent consumption). BackPressure mechanism, this mechanism can ensure that each node can control the speed of receiving data according to its own consumption capacity. When the node consumption speed cannot keep up with the production speed, the upstream node will store the excess data in the queue (if the queue is full, it will be discarded), which ensures the stability of the engine operation as a whole and will not fail due to peak data.

[0142] In view of the problem that conventional rule engines are difficult to expand when processing business data and other rule engines have built-in rule node functions that are insufficient to support business, the method provided in this embodiment is implemented based on the "interface-oriented" design concept, and all core functions are abstracted. When the built-in interface does not meet business needs, developers can customize rule nodes. Code implementation is interface-oriented, and interface-oriented code design can facilitate customizing rule nodes when existing nodes cannot meet business scenarios. If necessary, you can even customize scheduling strategies.

[0143] The following is an example of a custom rule node:

[0144] 1. Implement the TaskExecutorProvider interface

[0145] 2. Annotate @Component

[0146]

[0147]

[0148] When a conventional rule engine processes business data, the rule nodes of the conventional rule engine usually have file IO when exchanging data. Because IO is turned on, the rule engine consumes more resources and the node processing time is longer. For details, see Fig.11 , Fig.11 This is a schematic diagram of file IO. Fig.11 As shown, after the previous node writes (write) the file, the current node reads (read) from the file. The method provided in the embodiment of the present invention introduces a responsive distributed event bus EventBus, which is also developed based on Reactor3 and can support 10W data forwarding per second. Because of the support of EventBus, the rule nodes in the embodiment of the present invention use memory when transferring data, which greatly improves the speed compared to using files. Fig.12 , Fig.12 is a schematic diagram of another data flow provided by an embodiment of the present invention, such as Fig.12 As shown in the figure, the previous node writes (write) to the event bus, and there are multiple data (data) on the event bus. The current node then reads (read) from the event bus. Based on the responsive event bus Eventbus, data between nodes flows through memory without opening IO, which greatly improves the processing speed.

[0149] Combination Fig.13 As shown, Fig.13 Schematic diagram of an implementation framework in an embodiment of the present invention. Fig.13As shown in the figure, the data source can be connected to a variety of data sources, such as Kafka, MQ, MQTT, HTTP, db, etc. As the smallest working unit in the rule engine, the rule node (business logic rule node) has its own unique function and can run independently. The rule node includes multiple categories, such as general nodes, functional nodes, network nodes, data nodes, etc. Rules, each rule node is essentially a rule, which defines how the node should process data and what its function is; the rule parser can parse these rule definitions into executable rules. The rule engine core is the core of the rule engine, which includes three parts: rule parser, task scheduler, and executor. The rule parser parses the rule definition into an executable rule model, the task scheduler parses the rule model into tasks, and schedules it to the Worker for execution. The executor is the specific executor of the rule.

[0150] Data sources include, but are not limited to, Kafka, MQ (message queue), MQTT broker (MQTT agent, MQTT (Message Queuing Telemetry Transport), HTTP (Hypertext Transfer Protocol), db (database), where the database may be, for example, Oracle Database (also known as Oracle RDBMS, or Oracle for short), MySQL (relational database management system), SQLserver, PG (PostgreSQL), etc. In addition, if necessary, the data source may also be collected by the function node provided by the function node, and a specific file system may be used as the data source.

[0151] Rule parsing interface RuleEngineModelParser, this interface is mainly responsible for parsing the rule RULE. The rule RULE is essentially a JSON string that defines the rule. Before running, it needs to be parsed into a rule model (RuleModel).

[0152] RuleModel rule model, including metadata information of rules, including multiple RuleNodes (rule nodes) and RuleLinks (rule links).

[0153] The Scheduler task scheduler is responsible for converting the model into a job and scheduling it to a Worker. If the engine is running on a single machine, the default scheduler is LocalScheduler. If it is running on multiple nodes, the default scheduler is RemoteScheduler. You can customize the scheduler, such as implementing a load balancing scheduler.

[0154] Worker: Usually a server node, responsible for executing and maintaining tasks.

[0155] The Task rule executor is the place where tasks are executed and manages the entire life cycle of a task.

[0156] SchedleJob schedules tasks. When rules are published, RuleModel is parsed into jobs, which are then scheduled for execution by the scheduler.

[0157] TaskExecutor implements the logic of executing tasks. All the rule nodes mentioned above implement this interface. Through this interface, you can customize the nodes.

[0158] See also Fig.14 , Fig.14 FIG. 1 is a schematic diagram of the structure of an event flow design system based on a rule engine in an embodiment of the present invention. Fig.14 As shown, an embodiment of the present invention further provides an event flow design system 1400 based on a rule engine, and the event flow design system 1400 based on the rule engine includes: a rule editor interface 1401, the rule editor interface includes multiple types of business logic rule nodes, wherein each type corresponds to multiple business logic rule nodes; a node selection module 1402, used to select multiple business logic rule nodes as target rule nodes in the rule editing interface according to the business execution logic of the business to be created; a connection creation module 1403, used to create connections between target rule nodes based on the business process direction of the business execution logic; a rule configuration module 1404, used to configure business rules for each target rule node based on the business execution logic to complete the construction of the business rule engine for the business to be created; an adjustment module 1405, used to adjust the target rule nodes according to the changed business execution logic if the business execution logic of the business to be created changes, and adjust the connections between the adjusted target rule nodes to complete the construction of the business rule engine for the changed business to be created.

[0159] In one embodiment, the adjustment module is configured to: compare the business execution logic after the change with the business execution logic before the change to determine the logical differences; delete and / or add the target rule nodes based on the logical differences to adjust the target rule nodes; create connections between the adjusted target rule nodes according to the business process direction of the changed business execution logic to adjust the connections between the adjusted target rule nodes; configure new business rules for each of the adjusted target rule nodes based on the business execution logic.

[0160] In one embodiment, the system also includes a customization module, which is used to select multiple business logic rule nodes as target rule nodes in the rule editing interface according to the business execution logic of the business to be created. If the business logic rule nodes in the rule editing interface cannot meet the requirements of the business execution logic of the business to be created, a custom node is created according to the requirements of the business execution logic that cannot be met; and the custom node is used as the target rule node.

[0161] For the specific definition of the event stream design system based on the rule engine, please refer to the definition of the event stream design method based on the rule engine above, which will not be repeated here. Each module in the above-mentioned event stream design system based on the rule engine can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the electronic device in the form of hardware, or can be stored in the memory of the electronic device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0162] In this embodiment, the event flow design system based on the rule engine is essentially equipped with multiple modules to execute the event flow design method based on the rule engine in any of the above embodiments. The specific functions and technical effects can be referred to the above embodiments and will not be repeated here.

[0163] See also Fig.15 , Fig.15 is a schematic diagram of the structure of a rule engine in an embodiment of the present invention. Fig.15As shown, an embodiment of the present invention further provides a base rule engine 1500, which is substantially designed based on the event flow design method based on the rule engine in any of the above embodiments. The rule engine 1500 includes: a rule node 1510, a rule engine core 1530 and multiple business rules 1520, the rule engine core 1530 includes a rule parser 1531, a task scheduler 1532 and a rule executor 1533, wherein the rule node 1510 includes multiple rule sub-nodes, which are used to determine the target rule sub-node according to the data to be circulated provided by the data source, and determine at least one target business rule from the multiple business rules 1520 for the data to be circulated through the target rule sub-node; the rule parser 1531 is used to parse the business rules into executable rule models; the task scheduler 1532 is used to parse the executable rule model into tasks to be executed, and schedule them to corresponding task executors, the task executors are used to execute and maintain tasks, and the task executors include one or more rule executors; the rule executor 1533 is used to execute the tasks to be executed.

[0164] In this embodiment, the rule engine is substantially designed based on the event stream design method based on the rule engine in any of the above embodiments. The specific functions and technical effects can be referred to the above embodiments and will not be repeated here.

[0165] An embodiment of the present disclosure further provides an electronic device, including: a processor and a memory; the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory, so that the electronic device executes a method provided in any of the above embodiments.

[0166] The embodiment of the present application also provides a computer program product, including a computer program, which can implement the steps and corresponding contents of the aforementioned method embodiment when executed by a processor.

[0167] Fig.16 The structure diagram of the computer system suitable for implementing the electronic device of the embodiment of the present application is shown. It should be noted that: Fig.16 The computer system 2800 of the electronic device shown is only an example and should not bring any limitation to the functions and application scope of the embodiments of the present application.

[0168] like Fig.16As shown, the computer system 2800 includes a central processing unit (CPU) 2801, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 2802 or the program loaded from the storage part 2808 to the random access memory (RAM) 2803, such as executing the method in the above embodiment. In RAM 2803, various programs and data required for system operation are also stored. CPU 2801, ROM 2802 and RAM 2803 are connected to each other through bus 2804. I / O (Input / Output) interface 2805 is also connected to bus 2804.

[0169] The following components are connected to the I / O interface 2805: an input section 2806 including a keyboard, a mouse, etc.; an output section 2807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 2808 including a hard disk, etc.; and a communication section 2809 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 2809 performs communication processing via a network such as the Internet. A drive 2810 is also connected to the I / O interface 2805 as needed. A removable medium 2811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 2810 as needed so that a computer program read therefrom is installed into the storage section 2808 as needed.

[0170] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 2809, and / or installed from the removable medium 2811. When the computer program is executed by the central processing unit (CPU) 2801, various functions defined in the system of the present application are executed.

[0171] It should be noted that the computer-readable medium shown in the embodiment of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, an electrical, magnetic, optical, electromagnetic, infrared or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. A computer program contained on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0172] The electronic device disclosed in this embodiment includes a processor, a memory, a transceiver and a communication interface. The memory and the communication interface are connected to the processor and the transceiver and complete communication with each other. The memory is used to store computer programs, the communication interface is used to communicate, and the processor and the transceiver are used to run the computer program so that the electronic device executes each step of the above method.

[0173] It should be noted that the computer-readable medium shown in the embodiment of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, an electrical, magnetic, optical, electromagnetic, infrared or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. A computer program contained on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0174] The above description and accompanying drawings fully illustrate the embodiments of the present disclosure so that those skilled in the art can practice them. Other embodiments may include structural, logical, electrical, process and other changes. The embodiments represent possible changes only. Unless explicitly required, separate components and functions are optional, and the order of operation may vary. Parts and subsamples of some embodiments may be included in or replace parts and subsamples of other embodiments. Moreover, the words used in this application are only used to describe the embodiments and are not used to limit the claims. As used in the description of the embodiments and claims, unless the context clearly indicates, the singular forms of "a", "an" and "the" are intended to include plural forms as well. Similarly, the term "and / or" used in this application refers to any and all possible combinations of listings containing one or more associated ones. In addition, when used in the present application, the term "comprise" and its variants "comprises" and / or comprising refer to the presence of a stated sub-sample, whole, step, operation, element, and / or component, but do not exclude the presence or addition of one or more other sub-samples, wholes, steps, operations, elements, components and / or groups of these. In the absence of further restrictions, the elements defined by the sentence "comprising a ..." do not exclude the presence of other identical elements in the process, method or device comprising the elements. In this article, each embodiment may focus on the differences from other embodiments, and the same and similar parts between the various embodiments may refer to each other. For the methods, products, etc. disclosed in the embodiments, if they correspond to the method part disclosed in the embodiments, then the relevant parts can refer to the description of the method part.

[0175] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software may depend on the specific application and design constraints of the technical solution. Technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present disclosure. Technicians can clearly understand that for the convenience and simplicity of description, the specific working process of the systems, devices and units described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0176] In the embodiments disclosed herein, the disclosed methods and products (including but not limited to devices, equipment, etc.) can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units can be only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some sub-samples can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between each other shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms. The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to implement this embodiment. In addition, each functional unit in the embodiment of the present disclosure may be integrated in a processing unit, or each unit may exist physically alone, or two or more units may be integrated in one unit.

[0177] The flowchart and block diagram in the accompanying drawings show the possible architecture, functions and operations of the system, method and computer program product according to the embodiment of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and a part of the module, program segment or code contains one or more executable instructions for realizing the specified logical function. In some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which can depend on the functions involved. In the description corresponding to the flowchart and block diagram in the accompanying drawings, the operations or steps corresponding to different boxes can also occur in a different order from the order disclosed in the description, and sometimes there is no specific order between different operations or steps. For example, two consecutive operations or steps can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which can depend on the functions involved. Each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented by a dedicated hardware-based system that performs the specified functions or actions, or may be implemented by a combination of dedicated hardware and computer instructions.

Claims

1. An event flow design method based on a rule engine, characterized in that: The event flow design method based on the rule engine includes: Displaying a rule editor interface, wherein the rule editor interface includes multiple types of business logic rule nodes, wherein each type corresponds to multiple business logic rule nodes; Selecting multiple business logic rule nodes as target rule nodes in the rule editing interface according to the business execution logic of the business to be created; Create connections between target rule nodes based on the business process direction of the business execution logic; Based on the business execution logic, configure business rules for each of the target rule nodes to complete the construction of the business rule engine for the business to be created; If the business execution logic of the business to be created changes, the target rule nodes are adjusted according to the changed business execution logic, and the connections between the adjusted target rule nodes are adjusted to complete the construction of the business rule engine for the changed business to be created.

2. The event flow design method based on rule engine according to claim 1, characterized in that: The target rule nodes are adjusted according to the changed business execution logic, and the connections between the adjusted target rule nodes are adjusted, including: Compare the business execution logic after the change with the business execution logic before the change to determine the logic differences; Deleting and / or adding the target rule node based on the logic difference to adjust the target rule node; Create connections between adjusted target rule nodes according to the business process direction of the changed business execution logic to adjust the connections between the adjusted target rule nodes; A new business rule is configured for each of the adjusted target rule nodes based on the business execution logic.

3. The event flow design method based on rule engine according to claim 1, characterized in that: The types of the business logic rule nodes include general type, function type, network type and database type, wherein: The general type of business logic rule node includes at least one of the following: a timing task node for timingly triggering a downstream node, a delay node for rate control of node data, a routing node for determining a data transmission path, a listening completion node for monitoring the data processing execution completion status of a monitored node, a capture exception node for monitoring the abnormal status of a monitored node, and an annotation node for annotation; The business logic rule node of the functional type includes at least one of the following: a function node, an event bus event processing node for subscribing to an event bus data stream and performing data processing, an attribute subscription node for subscribing to device reported data, an attribute query node for querying the latest reported value of a device point, a device instruction node for sending instructions to a device, a write device node for writing data into time series data, an event subscription node for subscribing to device events, and a message notification node; The business logic rule node of the network type includes at least one of the following: a subscription node and a write node; The database type business logic rule node includes at least one of the following: a write database node and an execution node.

4. The event flow design method based on rule engine according to claim 1, characterized in that: After selecting a plurality of business logic rule nodes as target rule nodes in the rule editing interface according to the business execution logic of the business to be created, the method further includes: If the business logic rule node in the rule editing interface cannot meet the business execution logic requirements of the business to be created, create a custom node according to the business execution logic requirements that cannot be met; The custom node is used as the target rule node.

5. The event flow design method based on rule engine according to any one of claims 1 to 4, characterized in that: When data is transferred between the target rule nodes in the business rule engine, the target rule node as the data sending end publishes the data to be transferred to the distributed event bus to store the data to be transferred in the preset memory space, and the target rule node as the data receiving end obtains the data to be transferred from the preset memory space.

6. The event flow design method based on rule engine according to claim 5, characterized in that: The target rule node as a data receiving end obtains the data to be circulated from the preset memory space, including: The distributed event bus determines the target rule node corresponding to the data to be circulated based on a preset data subscription mapping relationship, where the preset data subscription mapping relationship is used to indicate a subscription mapping relationship between the data to be circulated and the target rule node; And push the data to be circulated to the target rule node, so that the target rule node reads the data to be circulated from the preset memory space.

7. The event flow design method based on rule engine according to claim 5, characterized in that: If the target rule node as the data receiving end processes the rules of the data to be circulated at a speed lower than the data publishing speed of the target rule node as the data sending end for publishing the data to be circulated to the distributed event bus, the target rule node as the data sending end is controlled to reduce the data publishing speed.

8. The event flow design method based on rule engine as claimed in claim 7, characterized in that: Controlling the target rule node as the data sending end to reduce the data publishing speed includes: storing the redundant data to be circulated in a first temporary queue, and discarding the data to be circulated first stored in the first temporary queue when the remaining data storage space of the first temporary queue is exhausted; or, The excess data to be circulated is stored in a first temporary queue, and when the remaining data storage space of the first temporary queue is exhausted, the data to be circulated first stored in the first temporary queue is sent to the first Kafka message queue, and after the rule processing speed is greater than the data publishing speed, the excess data to be circulated in the first Kafka message queue is pushed to the target rule node as the data receiving end, so as to perform rule processing on the excess data to be circulated through the business rules corresponding to the target rule node as the data receiving end.

9. An event stream design system based on a rule engine, characterized in that: The event stream design system based on the rule engine includes: A rule editor interface, wherein the rule editor interface includes multiple types of business logic rule nodes, wherein each type corresponds to multiple business logic rule nodes; A node selection module, used to select multiple business logic rule nodes as target rule nodes in the rule editing interface according to the business execution logic of the business to be created; A connection creation module, used to create connections between target rule nodes based on the business process of the business execution logic; A rule configuration module, used to configure business rules for each of the target rule nodes based on the business execution logic, so as to complete the construction of the business rule engine for the business to be created; The adjustment module is used to adjust the target rule nodes according to the changed business execution logic if the business execution logic of the business to be created changes, and adjust the connections between the adjusted target rule nodes to complete the construction of the business rule engine for the changed business to be created.

10. A rule engine, characterized in that: The rule engine is designed based on the event stream design method based on the rule engine according to any one of claims 1 to 8, the rule engine includes a rule node, a rule engine core and multiple business rules, the rule engine core includes a rule parser, a task scheduler and a rule executor, wherein: The rule node includes a plurality of rule sub-nodes, which are used to determine a target rule sub-node according to the data to be circulated provided by the data source, and determine at least one target business rule from a plurality of business rules for the data to be circulated through the target rule sub-node; The rule parser is used to parse the business rules into an executable rule model; The task scheduler is used to parse the executable rule model into tasks to be executed and schedule them to corresponding task executors. The task executors are used to execute and maintain tasks. The task executors include one or more rule executors. The rule executor is used to execute the task to be executed.

Citation Information

Cited By

  • Visual arrangement method and device for internet of things rule chain, medium, product and equipment

    CN120416043A