CN109783107B - Visual rule generation method and device and electronic equipment - Google Patents

Visual rule generation method and device and electronic equipment Download PDF

Info

Publication number
CN109783107B
CN109783107B CN201910023537.2A CN201910023537A CN109783107B CN 109783107 B CN109783107 B CN 109783107B CN 201910023537 A CN201910023537 A CN 201910023537A CN 109783107 B CN109783107 B CN 109783107B
Authority
CN
China
Prior art keywords
rule
memory
version number
redis
stored
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910023537.2A
Other languages
Chinese (zh)
Other versions
CN109783107A (en
Inventor
张瑞捷
覃祚海
程旭东
黄松深
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Xiaoying Information Technology Co ltd
Original Assignee
Shenzhen Xiaoying Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Xiaoying Information Technology Co ltd filed Critical Shenzhen Xiaoying Information Technology Co ltd
Priority to CN201910023537.2A priority Critical patent/CN109783107B/en
Publication of CN109783107A publication Critical patent/CN109783107A/en
Application granted granted Critical
Publication of CN109783107B publication Critical patent/CN109783107B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention provides a visual rule generation method, a visual rule generation device and electronic equipment, wherein the configuration of a rule is received through a visual interface; analyzing the rule configuration to obtain a rule analysis result; and loading the rule into a memory according to the rule analysis result and issuing the rule loaded in the memory. The invention compiles the rule through the visual interface, has high efficiency, is convenient for operation and understanding, has lower technical requirements on operators, and is completely independent and decoupled in the compiling of the rule and the analysis of the rule, thereby being convenient for the maintenance and the management of the rule.

Description

Visual rule generation method and device and electronic equipment
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for generating visualized rules, and an electronic device.
Background
The existing rule editing usually requires an operator to write a rule through a scripting language, and the technical requirements on the operator are very high, for example, an existing Drools rule engine is implemented as follows: drools is a rule engine implementation based on RATE algorithm written in Java language, supporting the writing of rules in scripting language to store and manage rules in drl files (data files). The defects of the existing rule editing are mainly as follows: (1) the entry threshold is high by compiling rules through a script language, and common operation and product personnel cannot configure the rules; (2) as traffic grows, the large number of rules drl files are difficult to maintain and manage.
Disclosure of Invention
In view of the above drawbacks of the prior art, an object of the present invention is to provide a visualized rule generating method, device and electronic device, which are used to solve the problems of complicated rule writing program, low efficiency, high technical requirements on operators, and the like, caused by only writing rules in a scripting language in the prior art.
To achieve the above and other related objects, the present invention provides a visualized rule generating method, including: receiving a configuration of rules through a visual interface; analyzing the configuration of the rule to obtain a rule analysis result; and loading the rule into a memory according to the rule analysis result and issuing the rule loaded in the memory.
In an embodiment of the present invention, the step of analyzing the configuration of the rule to obtain a rule analysis result further includes: and parsing the configuration of the rule into a Java source code, and compiling the configuration of the rule parsed into the Java source code into class byte codes capable of being operated by the Java virtual machine.
In an embodiment of the present invention, the memory includes a spring container and a rule registry, and the step of loading the rule into the memory according to the rule parsing result further includes: storing bean names corresponding to the rule analysis results in the rule registry, and storing rule instances corresponding to the bean names in the spring container; wherein the class bytecode is stored in the spring container.
In an embodiment of the present invention, the method further includes the step of executing the issued rule according to the rule execution request.
In an embodiment of the present invention, the step of running the issued rule further includes: and acquiring a bean name of the rule to be operated through the rule registry, and acquiring a corresponding rule instance from the spring container according to the bean name so as to operate the rule to be operated.
In an embodiment of the present invention, the method further includes a step of recycling the rule stored in the memory.
In an embodiment of the present invention, the rule to be recovered is marked as a to-be-recovered state in the rule registry, so that when the rule is recovered, the rule marked with the to-be-recovered state in the rule registry is recovered.
In an embodiment of the present invention, the method further includes a step of marking a memory version number of the rule in the rule registry.
In an embodiment of the present invention, the method further includes storing a latest version of the issued rule in redis and storing all the issued rules in a DB, and the step of executing the issued rule according to the rule execution request further includes: judging whether the rule operation request comprises a request version number or not, and if the rule operation request comprises the request version number, acquiring a rule corresponding to the request version number from the memory for operation; if the rule running request does not include the request version number and the redis is judged to be available, comparing a memory version number corresponding to a rule to be run and stored in the memory with a redis version number corresponding to the rule to be run and stored in the redis, updating the rule to be run and the memory version number stored in the memory according to the rule to be run and the redis version number of the redis version number stored in the redis when the rule versions of the two are different, and running the rule according to the updated rule to be run in the memory; and when the rule versions of the two are the same, directly executing the rule operation according to the rule to be operated stored in the memory.
In a specific embodiment of the present invention, if the rule running request does not include the request version number, and it is determined that the redis is not available and the DB is available, comparing a memory version number corresponding to a rule to be run stored in the memory with a latest DB version number corresponding to the rule to be run stored in the DB, and when the two rule versions are different, updating the rule to be run and the memory version number stored in the memory according to the rule to be run of the latest DB version number stored in the DB and the latest DB, and running the rule according to the updated rule to be run in the memory; and when the rule versions of the two are the same, directly executing the rule operation according to the rule to be operated stored in the memory.
In a specific embodiment of the present invention, if the rule running request does not include the request version number and it is determined that the redis and the DB are not available, the rule is directly run according to the rule to be run stored in the memory.
In an embodiment of the present invention, the states of the redis and the DB are detected with a preset heartbeat cycle to determine whether the redis and the DB are available.
To achieve the above and other related objects, the present invention further provides a visualized rule generating apparatus, including: a configuration module to receive a configuration of rules through a visualization interface; the analysis module is used for analyzing the configuration of the rule to obtain a rule analysis result; and the loading and issuing module is used for loading the rule into the memory according to the rule analysis result and issuing the rule loaded in the memory.
To achieve the above and other related objects, the present invention also provides an electronic device, comprising: a processor and a memory, the memory for storing a computer program, the processor for executing the computer program stored by the memory to cause the electronic device to execute the visualized rule generation method as described in any one of the above.
As described above, the visualized rule generation method, device and electronic device of the present invention receive the configuration of the rule through the visualized interface; analyzing the rule configuration to obtain a rule analysis result; and loading the rule into a memory according to the rule analysis result and issuing the rule loaded in the memory. The invention compiles the rule through the visual interface, has high efficiency, is convenient for operation and understanding, has lower technical requirements on operators, and is completely independent and decoupled in the compiling of the rule and the analysis of the rule, thereby being convenient for the maintenance and the management of the rule.
Drawings
Fig. 1 is a flow chart illustrating a visualized rule generating method according to an embodiment of the present invention.
Fig. 2 is an interface diagram of a visualized rule generating method according to an embodiment of the present invention.
Fig. 3 is a schematic diagram illustrating a rule parsing process applied in an embodiment of the invention.
Fig. 4 is a schematic diagram illustrating an application of the rule generating method according to an embodiment of the invention.
Fig. 5 is a schematic diagram illustrating an application of the rule generating method according to an embodiment of the invention.
Fig. 6 is a schematic block diagram of a visualized rule generating apparatus according to an embodiment of the present invention.
Fig. 7 is a schematic composition diagram of an electronic device according to an embodiment of the invention.
Description of the element reference numerals
10 visualization rule generating device
11 configuration module
12 analysis module
13 load release module
20 electronic device
21 processor
22 memory
S11-S13
Detailed Description
The embodiments of the present invention are described below with reference to specific embodiments, and other advantages and effects of the present invention will be easily understood by those skilled in the art from the disclosure of the present specification. The invention is capable of other and different embodiments and of being practiced or of being carried out in various ways, and its several details are capable of modification in various respects, all without departing from the spirit and scope of the present invention. It is to be noted that the features in the following embodiments and examples may be combined with each other without conflict.
It should be noted that the drawings provided in the following embodiments are only for illustrating the basic idea of the present invention, and the drawings only show the components related to the present invention rather than the number, shape and size of the components in actual implementation, and the type, quantity and proportion of the components in actual implementation may be changed freely, and the layout of the components may be more complicated.
Referring to fig. 1, a flow chart of a visualized rule generating method according to an embodiment of the invention is shown. The visualized rule generation method can be applied to an electronic device with a display screen, and comprises the following steps:
s11: receiving a configuration of rules through a visual interface; in some embodiments, a rule configuration interface may be displayed on the display screen, and the rule is visually edited according to the rule configuration interface, where the visual editing of the rule includes editing text content of the rule, editing a logical relationship, editing a trigger condition of an execution step in the rule, and the like, and is shown as an interface schematic diagram in a specific embodiment of the visual rule generating method of the present invention with reference to fig. 2. Fig. 2 forms a simple rule by connecting lines and editing the Chinese content of boxes, etc., i.e., members older than 18 years are shown as adults. In some embodiments, the display screen may be a touch display screen.
S12: analyzing the configuration of the rule to obtain a rule analysis result;
s13: and loading the rule into a memory according to the rule analysis result and issuing the rule loaded in the memory.
In specific application, the steps of receiving the configuration of the rule, issuing the rule and the like through the visual interface can be realized through a rule background service, and the steps of analyzing the rule, loading the rule, subsequently running the rule and the like can be realized through a rule engine service.
In some embodiments, the step of parsing the configuration of rules to obtain rule parsing results further comprises: and parsing the configuration of the rule into a Java source code, and compiling the configuration of the rule parsed into the Java source code into class byte codes capable of being operated by the Java virtual machine. The rules edited in the visual interface are analyzed into files in an xml format, and in the analyzing step, the files in the xml format are analyzed into Java source codes, and the configuration of the rules analyzed into the Java source codes is compiled into class byte codes capable of being operated by the Java virtual machine. The rule xml is parsed into java source codes, the java source codes meet groovy grammar, the groovy is a dynamic language supporting JVM (java virtual machine), the grammar of the groovy is similar to java and can be seamlessly butted with the java language, the groovy has the advantage of supporting dynamic compilation, groovy objects are dynamically compiled during service running, and the rule xml source codes are compiled into class bytecode capable of being run by the JVM through a groovy class loader.
Referring to fig. 3, fig. 3 is a schematic diagram illustrating a rule parsing process applied in an embodiment of the invention. In fig. 3, after a rule flow diagram is drawn on a visual page through a rule background service, the visual flow diagram is generated into a file in an xml format, the file in the xml format is sent to the rule engine service, and the file in the xml format is analyzed through an xercs, wherein the xercs is an xml parser of an open source code, and a code string is judged according to a splicing rule according to the file in the xml format, and a template replaces a keyword to generate a java class, and the regular java class is compiled into a class bytecode.
Referring to fig. 4, fig. 4 is a schematic diagram illustrating an application of the rule generating method of the present invention in an embodiment. The operation contents and data interaction mode of the rule background service and the rule engine service are shown in fig. 4. The rule background Service and the rule engine Service can be deployed on a plurality of network nodes, and the rule background Service and the rule engine Service among the nodes are subjected to load balancing through Service Mesh, wherein the Service Mesh is an infrastructure layer for processing communication among the services and is used for realizing reliable request transmission in a complex Service topology of cloud native application. In practice, the Service Mesh is typically a set of lightweight network proxies deployed with the application, but transparent to the application. The rule background service interacts with the network through an http interface, and the rule background service interacts with the rule engine service through the http interface. The rule management service is mainly used for rule management, rule group authority management, rule flow chart management, dimension variable management and the like. The rule engine service is mainly used for rule running, rule Java compiling, rule xml compiling, rule marking, rule Class instance management, rule registry management, rule recycling, rule offline, rule testing and the like.
And all data of the rule management service and the rule engine service in the running process are stored in the DB (database). And loading the rules which are already run and are currently run in the memory, and storing the rules of the latest version in the redis so as to update the rules of all nodes. Among them, redis a caching tool, has an expiration time, and has better performance than DB, so a layer of redis usually added on the DB in design to prevent penetration into DB, so as to prevent a large amount of data from accessing the Database (DB) in a flashing manner. The DB is specifically a relational database, and is a persistent storage scheme by default. The present invention stores all data, including rules, through the DB. The DB is already the lowest level of storage, and it can be understood that all that is stored forever is the most up-to-date data. The memory can not be stored persistently, the service is restarted, the data of the memory is destroyed, and the DB is a persistent tool, so that the data is stored in the DB, and the required data can be loaded from the DB when the data in the memory is destroyed. The performance of the memory operation is superior to that of the DB operation, so that the rule is loaded to the memory when the rule is operated for the first time, and the subsequent operation is performed in the memory, so that the DB operation is reduced, and the operation performance is improved. The rule is loaded into the memory to run, and the rule does not need to be extracted from the database every time, so that the rule running efficiency is effectively improved.
In addition, the rule java is converted into the byte code through the class loading mechanism of the JVM before the rule runs, namely, the step of compiling with high performance consumption is completed before the rule runs, and the rule is not required to be compiled again when a certain rule is run every time, so that the running efficiency of the rule is improved more effectively.
In some embodiments, the memory includes a spring container and a rule registry, and the step of loading the rule into the memory according to the rule parsing result further includes: storing bean names corresponding to the rule analysis results in the rule registry, and storing rule instances corresponding to the bean names in the spring container; wherein the class bytecode is stored in the spring container. Wherein the rules engine services include publication, execution, and reclamation of rules.
Namely, the visualized rule generating method further comprises a step of executing the issued rule according to the rule execution request.
In some embodiments, the step of executing the published rule further comprises: and acquiring a bean name of the rule to be operated through the rule registry, and acquiring a corresponding rule instance from the spring container according to the bean name so as to operate the rule to be operated.
The visualized rule generating method further includes a step of recovering the rule stored in the memory through a GC (Garbage Collection) in a JVM (java virtual machine), and specifically includes: and marking the rule to be recovered in the rule registry as a state to be recovered, so that the rule marked with the state to be recovered in the rule registry is recovered when the rule is recovered.
In some embodiments, the method further comprises the step of marking the memory version number of the rule in the rule registry. The rule generation method is also used for providing a control scheme with multiple versions of the rule through the rule engine service, one rule has multiple versions, the multiple versions are supported to run simultaneously, and the versions are independent and do not interfere with each other. Historical versions are not allowed to be modified and are also managed in memory, with historical version numbers being marked by a registry.
The invention also includes the step of running the rule in accordance with the rule-run request. Specifically, the step of storing the rule of the latest version issued in redis and storing all the issued rules in the DB, and the step of executing the issued rule according to the rule execution request further includes:
judging whether the rule operation request comprises a request version number or not, and if the rule operation request comprises the request version number, acquiring a rule corresponding to the request version number from the memory for operation; the request version number is typically a historical version number that has been run in memory.
If the rule running request does not include the request version number, running by defaulting to the latest version of rules in a memory, a redis and a DB, and comparing the memory version number corresponding to the rule to be run and stored in the memory with the redis version number corresponding to the rule to be run and stored in the redis when judging that the redis is available;
when the rule versions of the rule and the rule version number are different, updating the rule to be operated and the memory version number stored in the memory according to the rule to be operated and the redis version number of the redis version number stored in the redis, and operating the rule according to the updated rule to be operated in the memory;
and when the rule versions of the two are the same, directly executing the rule operation according to the rule to be operated stored in the memory.
If the rule running request does not include the request version number, and the redis is judged to be unavailable and the DB is available, comparing the memory version number corresponding to the rule to be run and stored in the memory with the latest DB version number corresponding to the rule to be run and stored in the DB;
when the rule versions of the rule and the rule are different, updating the rule to be operated and the memory version number stored in the memory according to the latest rule to be operated of the DB version number and the latest DB version number stored in the DB, and operating the rule according to the updated rule to be operated in the memory;
and when the rule versions of the two are the same, directly executing the rule operation according to the rule to be operated stored in the memory.
And if the rule running request does not include the request version number and the redis and the DB are judged to be unavailable, directly running the rule according to the rule to be run stored in the memory.
For example, the current rule in memory, DB or redis may be used for execution by the scheduler.
The invention also comprises the step of detecting the states of the redis and the DB according to a preset heartbeat cycle so as to judge whether the redis and the DB are available or not.
Specifically, an operator selects an interface operated according to a specified rule in a visual interface to operate the specified rule, obtains a comparison level of a current version, compares a rule version stored according to the redis with a version in a current memory when judging that the redis is available, operates according to the version in the redis when the two versions are different, and operates according to the version in the memory when the two versions are the same; when the redis is unavailable and the DB is available, comparing the rule version stored in the DB with the version in the current memory, when the two versions are different, operating according to the version in the DB, and when the two versions are the same, operating according to the version in the memory; and when both the redis and the DB are unavailable, operating according to the version in the current memory. And by carrying out heartbeat check on the redis and the DB, a result of the heartbeat check is timely sent to the scheduler, the scheduler judges whether to carry out version comparison according to the redis currently or to degrade the DB or to carry out version comparison or directly operate the version degraded into the memory according to the result of the heartbeat check on the redis and the DB, and the scheduler can also judge whether to directly operate according to the version in the memory or to upgrade the DB and operate after the version comparison or to upgrade the redis and operate after the version comparison according to the result of the heartbeat check on the redis and the DB.
The service degradation or upgrade scheme ensures that the rule operation interface does not depend on external resources strongly, so that the normal use of the rule operation interface is not influenced when a problem occurs in redis or DB.
The operation of the rules is illustrated below by way of an example:
1. the currently running rule A, version V1.
2. Rule A runs, first until Redis gets the latest version. If the version is found to be consistent with the in-memory version, the rule A of the V1 version is continuously run (possibly the version cannot be queried because no rule change occurs, and the current version is also run).
3. The rule background service updates rule A and publishes rule A, at which point the rule version is upgraded to V2. In the release process, the latest rule A is updated to a Database (DB), and meanwhile, the latest rule and the version number are stored to redis, and the expiration time is set.
4. And (4) operating the rule A, acquiring the latest version by redis, wherein the acquired version is V2, updating the rule to be V2 when the version is found to be upgraded, and operating the latest rule. If rule A is not run until the redis cache expires, the scheduler will upgrade the rule to version V2 within the redis expiration time, so there is no case of no update.
Fig. 5 is a schematic diagram illustrating an application of the rule generating method according to an embodiment of the invention. As can be seen from fig. 5, the Actor in the drawing creates a rule and a visual editing rule in the rule background service, parses the edited rule into an xml file, sends the xml file to an xml parser of the rule engine service for parsing into java source codes, sends the java source codes to a groovy parser to generate class bytecode, performs rule registration according to the class bytecode, and forms a rule instance to store in a spring context container. And the rule background service tests the generated rule and then releases the rule, and the rule is operated according to the rule engine service.
The spring is an open source framework of java, and one of the characteristics of the spring is management of the life cycle of a class instance, and the default is singleton (one class, only one instance is initialized). This property is exactly what is required by the rule class. Therefore, after the rule is instantiated, we give the reference of the rule instance to the spring container, which is managed by the spring container. And the spring life cycle is stopped along with the extinction of the whole service process.
The visualized rule generation method of the invention receives the configuration of the rule through the visualized interface; analyzing the configuration of the rule to obtain a rule analysis result; and loading the rule into a memory according to the rule analysis result and issuing the rule loaded in the memory. The invention compiles the rule through the visual interface, has high efficiency, is convenient for operation and understanding, has lower technical requirements on operators, and is completely independent and decoupled in the compiling of the rule and the analysis of the rule, thereby being convenient for the maintenance and the management of the rule.
Referring to fig. 6, fig. 6 is a schematic diagram illustrating a visualized rule generating device according to an embodiment of the invention. The visualized rule generating device 10 includes: a configuration module 11, a parsing module 12 and a load publishing module 13.
The configuration module 11 is configured to receive a configuration of rules through a visualization interface.
The analysis module 12 is configured to analyze the configuration of the rule to obtain a rule analysis result; in some embodiments, the parsing module 12 is further configured to parse the configuration of rules into Java source code, and compile the configuration of rules parsed into Java source code into class bytecode operable for the Java virtual machine.
The loading and issuing module 13 is configured to load the rule into the memory according to the rule analysis result and issue the rule loaded in the memory.
The memory includes a spring container and a rule registry, and the load release module 13 is further configured to store a bean name corresponding to the rule parsing result in the rule registry, and store a rule instance corresponding to the bean name in the spring container; wherein the class bytecode is stored in the spring container.
In some embodiments, the visualized rule generating apparatus 10 further includes a running module, configured to run the issued rule according to the rule running request. Specifically, for example, a bean name of the rule to be run is obtained through the rule registry, and the corresponding rule instance is obtained from the spring container according to the bean name to run the rule to be run.
In some embodiments, the visualized rule generating apparatus 10 further includes a recycling module, configured to recycle the rule stored in the memory, specifically, for example, mark the rule to be recycled as a state to be recycled in the rule registry, and recycle the rule marked with the state to be recycled in the rule registry when the rule is recycled.
The loading and issuing module 13 is further configured to mark a memory version number of a rule in the rule registry, store the rule of the latest version issued in redis and store all the issued rules in the DB, the running module is configured to determine whether the rule running request includes a request version number, and if the rule running request includes the request version number, obtain a rule corresponding to the request version number from the memory for running;
if the rule running request does not include the request version number and the redis is judged to be available, comparing a memory version number corresponding to a rule to be run and stored in the memory with a redis version number corresponding to the rule to be run and stored in the redis, updating the rule to be run and the memory version number stored in the memory according to the rule to be run and the redis version number of the redis version number stored in the redis when the rule versions of the two are different, and running the rule according to the updated rule to be run in the memory; and when the rule versions of the two are the same, directly executing the rule operation according to the rule to be operated stored in the memory.
If the rule running request does not include the request version number, and the redis is judged to be unavailable and the DB is available, comparing a memory version number corresponding to a rule to be run and stored in the memory with a latest DB version number corresponding to the rule to be run and stored in the DB, updating the rule to be run and the memory version number stored in the memory according to the rule to be run and the latest DB version number of the latest DB version number and stored in the DB when the rule versions of the two are different, and running the rule according to the updated rule to be run in the memory; and when the rule versions of the two are the same, directly executing the rule operation according to the rule to be operated stored in the memory.
And if the rule running request does not include the request version number and the redis and the DB are judged to be unavailable, directly running the rule according to the rule to be run stored in the memory.
The running module is further used for detecting the states of the redis and the DB in a preset heartbeat cycle to judge whether the redis and the DB are available.
The visualized rule generating device 10 is a device item corresponding to the visualized rule generating method, and both technical solutions correspond to each other, and all descriptions about the visualized rule generating method can be applied to this embodiment, which is not repeated herein.
Fig. 7 is a schematic diagram of an electronic device according to an embodiment of the invention. The electronic device 20 is, for example, a computer or a server running the visualized rule generating method, the electronic device 20 includes a processor 21 and a memory 22, the memory 22 is used for storing a computer program, and the processor 21 is used for executing the computer program stored in the memory 22, so as to enable the electronic device 20 to execute the visualized rule generating method, and the visualized rule generating method is described with reference to fig. 1 and the related description related to fig. 1.
The memory 22 may comprise high speed random access memory and may also comprise non-volatile memory, such as one or more magnetic disk storage devices, flash memory devices, or other non-volatile solid state storage devices. In certain embodiments, the memory 22 may also include memory 22 remote from the one or more processors 21, such as network-attached memory accessed via RF circuitry or external ports and a communication network, which may be the Internet, one or more intranets, Local Area Networks (LANs), wide area networks (WLANs), Storage Area Networks (SANs), and the like, or suitable combinations thereof. The memory controller may control access to the memory 22 by other components of the device, such as the CPU and peripheral interfaces.
The processor 21 is operatively coupled to a memory 22 and/or a non-volatile storage device. More specifically, the processor 21 may execute instructions stored in the memory 22 and/or the non-volatile storage device to perform operations in the computing device, such as generating and/or transmitting image data to an electronic display. As such, processor 21 may include one or more general purpose microprocessors, one or more application specific processors (ASICs), one or more field programmable logic arrays (FPGAs), or any combination thereof.
In summary, the visualized rule generating method, the visualized rule generating device and the electronic device receive the configuration of the rule through the visualized interface; analyzing the configuration of the rule to obtain a rule analysis result; and loading the rule into a memory according to the rule analysis result and issuing the rule loaded in the memory. The invention compiles the rule through the visual interface, has high efficiency, is convenient for operation and understanding, has lower technical requirements on operators, and is completely independent and decoupled in the compiling of the rule and the analysis of the rule, thereby being convenient for the maintenance and the management of the rule. Therefore, the invention effectively overcomes various defects in the prior art and has high industrial utilization value.
The foregoing embodiments are merely illustrative of the principles and utilities of the present invention and are not intended to limit the invention. Any person skilled in the art can modify or change the above-mentioned embodiments without departing from the spirit and scope of the present invention. Accordingly, it is intended that all equivalent modifications or changes which can be made by those skilled in the art without departing from the spirit and technical spirit of the present invention be covered by the claims of the present invention.

Claims (9)

1. A method for generating rules for visualization, comprising:
receiving a configuration of rules through a visual interface;
analyzing the configuration of the rule to obtain a rule analysis result;
loading the rule into a memory according to the rule analysis result and issuing the rule loaded in the memory;
running the issued rule according to the rule running request;
storing the most recent version of the rule issued in redis and storing all the rules issued in a DB;
wherein the step of parsing the configuration of the rule to obtain a rule parsing result further comprises: analyzing the rule configuration into a Java source code, and compiling the rule configuration analyzed into the Java source code into a class bytecode which can be used for the operation of a Java virtual machine;
the memory includes a spring container and a rule registry, and the step of loading the rule into the memory according to the rule analysis result further includes: storing bean names corresponding to the rule analysis results in the rule registry, storing rule instances corresponding to the bean names in the spring container, and marking memory version numbers of rules in the rule registry; wherein the class bytecode is stored in the spring container;
the step of executing the issued rule according to the rule execution request further includes: judging whether the rule operation request comprises a request version number or not, and if the rule operation request comprises the request version number, acquiring a rule corresponding to the request version number from the memory for operation; if the rule running request does not include the request version number and the redis is judged to be available, comparing a memory version number corresponding to the rule to be run and stored in the memory with a redis version number corresponding to the rule to be run and stored in the redis, updating the rule to be run and the memory version number stored in the memory according to the rule to be run and the redis version number of the redis version number and stored in the redis when the rule versions of the two are different, and running the rule according to the updated rule to be run in the memory; and when the rule versions of the two are the same, directly executing the rule operation according to the rule to be operated stored in the memory.
2. The visualized rule generation method of claim 1, wherein the step of executing the published rule further comprises: and acquiring a bean name of the rule to be operated through the rule registry, and acquiring a corresponding rule instance from the spring container according to the bean name so as to operate the rule to be operated.
3. The visualized rule generating method of claim 1, further comprising a step of recycling the rules stored in the memory.
4. The visualized rule generating method of claim 3, wherein the rule to be recovered is marked as a to-be-recovered state in the rule registry, so that when a rule is recovered, the rule marked with the to-be-recovered state in the rule registry is recovered.
5. The visual rule generating method of claim 1, wherein if the rule running request does not include the request version number and the redis is determined to be unavailable and the DB is available, comparing the memory version number corresponding to the rule to be run stored in the memory with the latest DB version number corresponding to the rule to be run stored in the DB,
when the rule versions of the rule and the rule are different, updating the rule to be operated and the memory version number stored in the memory according to the latest rule to be operated of the DB version number and the latest DB version number stored in the DB, and operating the rule according to the updated rule to be operated in the memory;
and when the rule versions of the two are the same, directly executing the rule operation according to the rule to be operated stored in the memory.
6. The visual rule generating method of claim 1, wherein if the rule running request does not include the request version number and it is determined that both the redis and the DB are unavailable, the rule is run directly according to the rule to be run stored in the memory.
7. The visualized rule generating method of claim 1, wherein the states of the redis and the DB are checked at a preset heartbeat cycle to determine whether the redis and the DB are available.
8. A visualized rule generating apparatus, comprising:
a configuration module to receive a configuration of rules through a visualization interface;
the analysis module is used for analyzing the configuration of the rule to obtain a rule analysis result;
the loading and issuing module is used for loading the rule into the memory according to the rule analysis result and issuing the rule loaded in the memory;
the visualized rule generating device is further used for executing the following processes: running the issued rule according to the rule running request; storing the most recent version of the rule issued in redis and storing all the rules issued in a DB;
wherein the process of parsing the configuration of the rule to obtain a rule parsing result further comprises: analyzing the rule configuration into a Java source code, and compiling the rule configuration analyzed into the Java source code into a class bytecode which can be used for the operation of a Java virtual machine;
the memory includes a spring container and a rule registry, and the process of loading the rule into the memory according to the rule analysis result further includes: storing bean names corresponding to the rule analysis results in the rule registry, storing rule instances corresponding to the bean names in the spring container, and marking memory version numbers of rules in the rule registry; wherein the class bytecode is stored in the spring container;
the process of executing the issued rule according to the rule execution request further includes: judging whether the rule operation request comprises a request version number or not, and if the rule operation request comprises the request version number, acquiring a rule corresponding to the request version number from the memory for operation; if the rule running request does not include the request version number and the redis is judged to be available, comparing a memory version number corresponding to a rule to be run and stored in the memory with a redis version number corresponding to the rule to be run and stored in the redis, updating the rule to be run and the memory version number stored in the memory according to the rule to be run and the redis version number of the redis version number stored in the redis when the rule versions of the two are different, and running the rule according to the updated rule to be run in the memory; and when the rule versions of the two are the same, directly executing the rule operation according to the rule to be operated stored in the memory.
9. An electronic device, comprising: a processor and a memory, the memory for storing a computer program, the processor for executing the computer program stored by the memory to cause the electronic device to perform the visualized rule generation method of any of claims 1-7.
CN201910023537.2A 2019-01-10 2019-01-10 Visual rule generation method and device and electronic equipment Active CN109783107B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910023537.2A CN109783107B (en) 2019-01-10 2019-01-10 Visual rule generation method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910023537.2A CN109783107B (en) 2019-01-10 2019-01-10 Visual rule generation method and device and electronic equipment

Publications (2)

Publication Number Publication Date
CN109783107A CN109783107A (en) 2019-05-21
CN109783107B true CN109783107B (en) 2022-05-24

Family

ID=66500350

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910023537.2A Active CN109783107B (en) 2019-01-10 2019-01-10 Visual rule generation method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN109783107B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110941420A (en) * 2019-11-22 2020-03-31 绿漫科技有限公司 Rule engine system and method based on Actor model
CN111427789B (en) * 2020-03-26 2022-08-16 平安医疗健康管理股份有限公司 Method, device, computer equipment and storage medium for automatically verifying rule
CN112488855B (en) * 2020-11-23 2024-02-13 中国人寿保险股份有限公司 Business verification method and device based on rule template
CN113885961A (en) * 2021-10-09 2022-01-04 上海得帆信息技术有限公司 Method for visually realizing formula rules of aPaaS platform

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104715001A (en) * 2013-12-12 2015-06-17 国际商业机器公司 Method and system performing wirite operation on shared resource in cluster of data processing system
CN107315611A (en) * 2017-06-26 2017-11-03 郑州云海信息技术有限公司 A kind of application system regulation management method and device
CN107632842A (en) * 2017-09-26 2018-01-26 携程旅游信息技术(上海)有限公司 Rule configuration and dissemination method, system, equipment and storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104715001A (en) * 2013-12-12 2015-06-17 国际商业机器公司 Method and system performing wirite operation on shared resource in cluster of data processing system
CN107315611A (en) * 2017-06-26 2017-11-03 郑州云海信息技术有限公司 A kind of application system regulation management method and device
CN107632842A (en) * 2017-09-26 2018-01-26 携程旅游信息技术(上海)有限公司 Rule configuration and dissemination method, system, equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
Spring框架在模型层的应用及原理;温立辉;《福建电脑》;20170525(第5期);第147-148页 *

Also Published As

Publication number Publication date
CN109783107A (en) 2019-05-21

Similar Documents

Publication Publication Date Title
CN109783107B (en) Visual rule generation method and device and electronic equipment
US9904522B2 (en) Web development system
JP5357885B2 (en) Managing updates to create virtual machine clones
US8875306B2 (en) Customization restrictions for multi-layer XML customization
US8966465B2 (en) Customization creation and update for multi-layer XML customization
US11429365B2 (en) Systems and methods for automated retrofitting of customized code objects
US7454745B2 (en) Automated semantic-based updates to modified code base
US8538998B2 (en) Caching and memory optimizations for multi-layer XML customization
US8788542B2 (en) Customization syntax for multi-layer XML customization
US20110296391A1 (en) Systems and Methods for Dynamically Replacing Code Objects Via Conditional Pattern Templates
US20090204884A1 (en) Multi-layer xml customization
US20080250392A1 (en) Content management system for computer software with dynamic traceability between code and design documents
US8438557B2 (en) Reusing an application object
CN104679500B (en) Method and device for realizing automatic generation of entity class
CN115599386A (en) Code generation method, device, equipment and storage medium
CN116301951B (en) Micro-service application installation upgrading method and device based on kubernetes
CN110968339A (en) Method and device for front-end construction tool and electronic equipment
CN110162299A (en) Web program and its Quick Development Framework, development approach and relevant device
US20180032510A1 (en) Automated translation of source code
CN113031964B (en) Big data application management method, device, equipment and storage medium
CN115129348A (en) Resource updating method, device and equipment of application program and readable storage medium
CN113791809A (en) Application exception handling method and device and computer readable storage medium
KR20040050463A (en) Appratus and Method for Enterprise JavaBean Component Testing
US20240160412A1 (en) Non-intrusive build time injection tool for accelerating launching of cloud applications
CN113626423B (en) Log management method, device and system of business database

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant