CN109783151B - Method and device for rule change - Google Patents

Method and device for rule change Download PDF

Info

Publication number
CN109783151B
CN109783151B CN201711103749.9A CN201711103749A CN109783151B CN 109783151 B CN109783151 B CN 109783151B CN 201711103749 A CN201711103749 A CN 201711103749A CN 109783151 B CN109783151 B CN 109783151B
Authority
CN
China
Prior art keywords
rule
engine
application system
change
new
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
CN201711103749.9A
Other languages
Chinese (zh)
Other versions
CN109783151A (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.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke 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 Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201711103749.9A priority Critical patent/CN109783151B/en
Publication of CN109783151A publication Critical patent/CN109783151A/en
Application granted granted Critical
Publication of CN109783151B publication Critical patent/CN109783151B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The embodiment of the invention provides a method and a device for rule change, which can realize dynamic change of rules, and when the rules are changed, the rule matching is not paused, and the project does not need to be stopped; in addition, real-time notification of rule changes can also be implemented. The method comprises the following steps: a new rule engine is pre-constructed according to the change rule acquired from the rule issuing center; and before the new rule engine is pre-constructed, the original rule engine is used for rule matching, and after the new rule engine is pre-constructed, the new rule engine is used for rule matching.

Description

Method and device for rule change
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for rule change.
Background
In the running process of the application system, the condition for carrying out logic judgment is the system rule. For example, someone cannot access the enterprise management system, or reimbursement below 1000 dollars does not require a chief supervision and review, etc. In the process of system operation, the situation that system rules need to be changed according to actual requirements may be involved.
In the prior art, the following two schemes of rule change are generally adopted:
first, application system is stopped to change rule
After the application system is started, loading the rule files in the project, stopping the project when the rules are changed, updating the rule files, and restarting the project to reload the rule files;
rule change based on rule polling and thread blocking
After the application system is started, the rule management center is inquired at intervals to judge whether the rule changes. And when the rule is found to be changed, the rule in the rule application is checked, and the rule in the rule engine is changed.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art:
1. in the rule changing process, the current business is blocked and stopped, and the project is interrupted; 2. the rule is not changed in time; 3. all application systems poll the management center, and the rule management center is over stressed.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for rule change, which can implement dynamic change of rules, and when a rule is changed, rule matching is not suspended, and an item does not need to be stopped; in addition, real-time notification of rule changes can also be implemented.
To achieve the above object, according to an aspect of an embodiment of the present invention, a method of rule change is provided.
The rule changing method of the embodiment of the invention comprises the following steps: a new rule engine is pre-constructed according to the change rule acquired from the rule issuing center; and before the new rule engine is pre-constructed, the original rule engine is used for rule matching, and after the new rule engine is pre-constructed, the new rule engine is used for rule matching.
Optionally, in the method, a rule publishing center is constructed based on a ZooKeeper server.
Optionally, before pre-constructing a new rule engine according to the change rule obtained from the rule issuing center, the method further includes: embedding a rule engine package before an application system is started; and after the application system is started, initializing a rule engine by using the rule engine package according to the initial rule acquired from the rule issuing center.
Optionally, the method further comprises: and storing the rule acquired from the rule issuing center to the local.
Optionally, before pre-constructing a new rule engine according to the change rule obtained from the rule issuing center, the method further includes: establishing an application system node in the rule issuing center, and registering a rule change monitoring event on the application system node; and acquiring a change rule which is pushed to the application system node by the rule management center after the rule is changed.
Optionally, the method further comprises: in the process of pre-constructing a new rule engine according to change rules acquired from a rule issuing center, determining the range of an application system server applicable to the new rule engine and/or the effective time of the new rule engine according to a rule change strategy pre-configured in the rule issuing center.
To achieve the above object, according to another aspect of the embodiments of the present invention, there is provided an apparatus for rule modification.
The rule changing device of the embodiment of the invention comprises: the pre-construction module is used for pre-constructing a new rule engine according to the change rule acquired from the rule issuing center; and the matching module is used for matching the rules by using the original rule engine before the new rule engine is pre-constructed and matching the rules by using the new rule engine after the new rule engine is pre-constructed.
Optionally, in the apparatus, the rule issuing center is constructed based on a ZooKeeper server.
Optionally, the apparatus further comprises: the rule engine initialization module is used for embedding a rule engine package before the application system is started; and after the application system is started, initializing a rule engine by using the rule engine package according to the initial rule acquired from the rule issuing center.
Optionally, the apparatus further comprises: and the storage module is used for storing the rule acquired from the rule issuing center to the local.
Optionally, the apparatus further comprises: the rule monitoring module is used for establishing an application system node in the rule issuing center and registering a rule change monitoring event on the application system node; and acquiring a change rule which is pushed to the application system node by the rule management center after the rule is changed.
Optionally, the pre-construction module is further configured to: and determining the range of the application system server applicable to the new rule engine and/or the effective time of the new rule engine according to a rule change policy pre-configured in the rule issuing center.
To achieve the above object, according to still another aspect of embodiments of the present invention, there is provided an electronic apparatus.
An electronic device of an embodiment of the present invention includes: one or more processors; a storage device, configured to store one or more programs, which when executed by the one or more processors, cause the one or more processors to implement the method of rule change of the embodiment of the present invention.
To achieve the above object, according to still another aspect of an embodiment of the present invention, there is provided a computer-readable medium.
A computer-readable medium of an embodiment of the present invention has a computer program stored thereon, which when executed by a processor implements the method of rule change of an embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: because the technical means of pre-constructing the rule engine is adopted in the rule changing process, the technical problem that the rule matching is forced to pause because the project needs to be stopped in the rule changing process in the prior art is solved, the dynamic rule changing is further realized, the project does not need to be stopped, the technical effect that the rule matching is not paused while the rule is changed is achieved, and the smooth and stable operation of an application system is ensured; by constructing the rule issuing center based on the ZooKeeper, the distributed and real-time rule pushing can be conveniently realized; embedding a rule engine jar packet into an application system before the application system is started, and initializing a rule engine after an initial rule is acquired, so that the application system can conveniently perform rule matching according to the transmitted parameters; when the rules are changed, the original rule engine can be continuously adopted to carry out rule matching before the new rule engine which is pre-constructed is not constructed, so that the project does not need to be stopped, and the rule matching does not need to be stopped; the initial rules and the change rules acquired from the rule issuing center are stored to the local of the application system, so that the rules can be still acquired from the local to construct a rule engine in the application system under the condition that the rule issuing center crashes, and the dependency of the application system on the rule issuing center and the rule management center can be reduced; through the mechanism of the layered storage, the pressure of an application system for accessing the rule management center can be reduced to the maximum extent, and the stability of the rule management center is improved; by establishing an application system node in the rule issuing center and registering a monitoring event, the changed rule can be acquired in real time when the rule is changed; by pre-configuring the rule change strategy in the rule issuing center, the gray level issuing of the rule can be realized according to the rule issuing requirement or the rule engine effective time can be flexibly adjusted according to the actual requirement.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of a main flow of a method of rule change according to an embodiment of the invention;
FIG. 2 is a block diagram of an overall framework of a system suitable for implementing the method of rule change of an embodiment of the invention;
FIG. 3 is a logic diagram of rule issuing according to a rule change method of an embodiment of the invention;
FIG. 4 is a timing diagram illustrating the operation of a rule change implemented by a rule change method according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of a rule hierarchy store according to a method of rule change in an embodiment of the invention;
FIG. 6 is a schematic diagram of the major modules of a rule-altering apparatus according to an embodiment of the present invention;
FIG. 7 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 8 is a schematic structural diagram of a computer system suitable for implementing a terminal device or a server according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
The technical scheme of the rule change of the embodiment of the invention realizes the non-pause of rule matching in the rule change process by utilizing the rule issuing center to change the rules in real time and adopting a mode of pre-constructing a rule engine in the rule change process.
The following is an explanation of some technical terms involved in the embodiments of the present invention:
clustering: computing work is done with a high degree of closeness of cooperation through a set of loosely integrated computer software and/or hardware connections;
distributed: a set of computers (computers) linked to each other via a network to transmit messages and communications and to coordinate their activities to form a system;
http: the hypertext Transfer Protocol (HTTP, H8perTe7t Transfer Protocol) is one of the most widely used network protocols on the internet;
reverse proxy server: the mode is that the proxy server receives a connection request on the internet, then forwards the request to a server on an internal network, and returns a result obtained from the server to a client requesting connection on the internet, and the proxy server is represented as a reverse proxy server to the outside at the moment;
long connection: during the connection holding period, if no data packet is sent, both sides are required to send a link detection packet;
a rule engine: the method is a component embedded in an application program, and realizes the separation of business decisions from application program codes and the writing of the business decisions by using a predefined semantic module. Receiving data input, explaining a business rule, and making a business decision according to the business rule;
the rule management system comprises: the system is constructed based on an open source rule engine drools, and is used for editing, releasing and verifying rules. The rule management system in the embodiment of the invention can also be constructed based on other rule engines, such as visual rules, iLog and the like, and the action principles are the same. The rule management system in the embodiment of the invention can be considered to be composed of a rule management center, a rule issuing center and a rule engine embedded into an application system;
the rule matching means that the rule engine judges conditions according to the transmitted parameters, and the parameters match with which rule in the engine;
ZooKeeper: ZooKeeper is a distributed, open source code distributed application program coordination service, which comprises a simple primitive set, and the distributed application program can realize synchronization service, configuration maintenance and naming service and the like based on the ZooKeeper;
zookeeper has the following characteristics:
1. final consistency: the client is shown to be the same view no matter which Server is connected to, which is the most important performance of the ZooKeeper;
2. reliability: with simple, robust, good performance, if a message m is accepted by one server, it will be accepted by all servers;
3. real-time performance: zookeeper ensures that the client will obtain the updated information of the server or the information of the server failure within a time interval range. However, because of network delay and other reasons, Zookeeper cannot guarantee that two clients can obtain the data just updated at the same time, and if the latest data is needed, the s8nc () interface should be called before reading the data;
4. wait-free (wait-free): slow or invalid clients must not intervene in the request of fast clients, so that each client can effectively wait;
5. atomicity: updates can only succeed or fail, with no intermediate states;
6. sequentially: the method comprises the following steps of global ordering and partial ordering: global ordering means that if message a is published before message b on one Server, message a will be published before message b on all servers; partial ordering means that if a message b is issued by the same sender after a message a, a must be placed before b.
Memory: an electronic device using semiconductor technology for storing data;
and (6) Maven: is a project management and integration tool. Maven provides a developer to build a complete lifecycle framework. The development team can automatically complete the infrastructure of the project, Maven builds the lifecycle using standard directory structures and defaults. In the embodiment of the invention, a rule engine jar packet is embedded into an application system by using Maven to realize the initialization of the rule engine;
nginx: is a high performance HTTP and reverse proxy server;
tomcat: is a free Web application server with open source code. In the embodiment of the present invention, the rule management center may be a rule management cluster composed of Tomcat application servers.
Fig. 1 is a schematic diagram of a main flow of a method of rule change according to an embodiment of the present invention.
As shown in fig. 1, the method for rule modification according to the embodiment of the present invention mainly includes the following steps:
step S101: and pre-constructing a new rule engine according to the change rule acquired from the rule issuing center. The purpose of this step is to realize that the application system acquires the changed system rule in real time. In the embodiment of the invention, the rule issuing center can be constructed based on the ZooKeeper server. The real-time release of the change rule can be realized through a monitoring mechanism of the ZooKeeper.
In the process of pre-constructing the rule engine according to the change rule in step S101, the method for changing the rule according to the embodiment of the present invention may further implement the non-stop rule matching. As shown in step S102.
Step S102: and before the new rule engine is pre-constructed, the original rule engine is used for rule matching, and after the new rule engine is pre-constructed, the new rule engine is used for rule matching. Namely, in the rule changing process, project interruption is not needed, and the pause of rule matching is not needed. When an external user accesses the application system to judge the condition, the application system selects the rule engine to match the rule according to the input parameters, and the project needs to be interrupted and the application system is restarted without the need of rule change in the prior art.
In the embodiment of the present invention, before a new rule engine is pre-constructed according to a change rule obtained from a rule issuing center, the method further includes: before an application system is started, embedding a rule engine package into the application system, wherein the rule engine package is a rule engine jar package in the embodiment of the invention; and after the application system is started, initializing a rule engine by using the rule engine package according to the initial rule acquired from the rule issuing center.
In the method for changing a rule according to the embodiment of the present invention, the initial rule and the change rule obtained from the rule issuing center may be stored locally, for example, but not limited to, in a local disk. Therefore, when the rule issuing center crashes, the rules can be acquired locally from the application system to construct the rule engine.
Before a new rule engine is pre-constructed according to a change rule obtained from a rule issuing center, the method for changing the rule according to the embodiment of the present invention may further include: establishing an application system node in the rule issuing center, and registering a rule change monitoring event on the application system node; and after the rule is changed, acquiring the change rule pushed to the application system node by the rule management center, and pre-constructing a new rule engine according to the acquired change rule.
In the process of pre-constructing a new rule engine according to a change rule acquired from a rule issuing center, the range of an application system server applicable to the new rule engine and/or the effective time of the new rule engine can be determined according to a rule change strategy pre-configured in the rule issuing center, so that the gray level issuing of the rule can be realized, or the effective time of the rule engine can be set according to actual requirements.
Fig. 2 is a general framework diagram of a system suitable for implementing the method of rule change of the embodiment of the present invention.
As shown in fig. 2, in the embodiment of the present invention, the rule management system for implementing the method of changing the rule mainly includes a rule management center, a rule issuing center, and a rule engine included in an application system.
Wherein, the rule management center mainly edits the rule and checks the rule; the application system obtains the rules from the rule issuing center under the normal condition of the rule issuing center, and can directly obtain the rules from a local disk of the application system or obtain the rules from the rule management center under the condition of crash of the rule issuing center, and the hierarchical storage mechanism of the rules is favorable for improving the high availability of the rule management system; in addition, the rule issuing center using the monitoring mechanism of the ZooKeeper node can realize asynchronous rule change notification to the application system.
In the embodiment of the invention, if the rule issuing center is not included, the change of the rule can be roughly carried out by regularly polling the rule management center by the application system or adopting a scheme of carrying out rule change notification by using the message queue MQ. In the first scheme, an application system needs to regularly poll a rule management center, and the scheme has the defects that the rule is not changed timely, and a polling mechanism can cause great access pressure to the rule management center to influence the rule editing test; in the second scheme, a message queue MQ is adopted to carry out rule change notification, and the scheme has the defect that if the rule change of the application system fails, the rule change cannot be acquired from the message queue MQ again.
In the embodiment of the invention, different rule change policies, such as the regular effectiveness of the rule engine at fixed time or the instant effectiveness, can be set for different application systems in the rule issuing center. In addition, the rule issuing center can also perform directional issuing on a certain machine of a certain application system server cluster, so that the gray level issuing of the rule is facilitated. The rule issuing center can configure the changed rule to take effect on which machine of the cluster, and the rule execution effect is judged by observing the operation result of a single machine, so that the influence on a wider range when the rule configuration has problems is avoided.
Fig. 3 is a logic diagram of rule issuing according to the rule changing method in the embodiment of the present invention.
As shown in fig. 3:
1) the rule management center initializes a system node of the rule issuing center and stores rule data under the system node;
2) the application system establishes connection with the rule issuing center by using a ZooKeeper monitoring mechanism of the rule issuing center, and monitors respective system node changes through registration rule change events. A monitoring mechanism based on the registration event avoids a time interval caused by polling data, and once the rule changes, the application system immediately senses the change;
3) in the rule issuing center, different application system nodes monitor the corresponding rule master node, when the rule changes, the rule management center can push the change rule to each system node through the rule master node, and the system node which does not change the rule is not influenced.
Fig. 4 is a schematic diagram of an operation timing sequence of implementing rule change according to the rule change method of the embodiment of the present invention.
As shown in fig. 4:
in the embodiment of the invention, when the application system is started, a rule engine is initialized, when the rule of the application system is changed, the pre-construction process is carried out, and after the construction is finished, the original rule engine is replaced. In the process of rule change, the rule change is carried out by adopting a mode of pre-constructing a new rule engine, and the pause of rule matching of an application system caused by rule change is avoided by constructing the new rule engine to be put into a cache. As shown in fig. 4, a user accessing the application system uses the original rule engine for matching without building a new rule engine, and simultaneously builds a new rule engine in the memory of the application system; after the new rule engine is built, matching is performed by using the new rule engine. Therefore, in the embodiment of the invention, when the rule matching rule of the rule engine is called, whether a new rule engine exists in the cache is checked, if the new rule engine exists, the new rule engine is used for matching, and the old rule engine is deleted, so that the non-blocking of rule matching is realized.
In the embodiment of the invention, if a pre-constructed mode is not adopted, the rule engine is required to refresh the rule (namely, the rule engine rule needs to be refreshed when the original rule engine changes the rule) in the rule changing and taking effect process, and the current service thread needs to be blocked when the rule engine refreshes the rule and the rule matching cannot be carried out, so that the execution efficiency of the service is influenced when the rule is changed, and the response time of an application system is prolonged.
In the embodiment of the invention, the rule engine is pre-constructed, so that the rule matching can be realized without stopping, and the range of the server of the application system suitable for the new rule engine or the time when the rule engine takes effect can be determined according to the rule change strategy pushed by the rule issuing center. If the original rule engine is used for rule refreshing, the rule change strategy cannot be realized on the level of the rule engine.
Fig. 5 is a schematic diagram of a rule hierarchical storage according to a rule change method in an embodiment of the present invention.
As shown in fig. 5:
1) under normal conditions, the application system communicates with the rule issuing center to acquire the rules without depending on the rule management center, so that the application system is not influenced to carry out normal rule loading under the condition that the service cannot be provided due to system updating or system faults of the rule management center;
2) the rule issuing center does not update programs, but in an extreme case, when the rule issuing center cannot provide services, the application system can build a rule engine in the application system by loading the rule files cached in the local disk, so that the dependency of the application system on the rule issuing center is reduced. And the influence of the rule management system on the application system is reduced to the maximum extent through a layered storage mechanism.
In summary, in the embodiment of the present invention, the main implementation steps for implementing the rule changing scheme are as follows:
management center for deployment rules
And deploying a tomcat rule management center cluster based on the Nginx agent, and detecting and initializing relevant nodes of the rule management center when the rule management center is started. The detection of the rule management center cluster comprises the following steps: the Nginx proxy server detects each server in the rule management center cluster by, for example but not limited to, sending an http request to the Tomcat application server at regular time, judges whether the application server normally operates according to a response result, and rejoins the application server if the application server is abnormally lifted out of the cluster and is recovered.
Second, deployment rule publishing center
At least 2N +1 stations are selected as a ZooKeeper server, the ZooKeeper service is installed, and the ZooKeeper automatically selects a manager leader to be responsible for ZooKeeper cluster management. When a cluster machine leader fails, a new leader is elected from the cluster machine leader to coordinate services, so as to ensure the availability of external services. The purpose of selecting odd servers is to prevent the condition that the leader cannot be selected due to the fact that the tickets of two machines are equal in the leader election process.
Embedding the rule engine into an application system in a jar package mode
The application system introduces a rule engine jar packet in a Maven mode, performs initialization of a rule engine and registration of a rule change event in a rule issuing center when the application system is started, and caches the rule of the application system in a disk of the server.
Fourthly, rule change publishing
When a business person maintains a new rule in the rule management center, and after the issuing operation of the change rule is carried out, the rule issuing center notifies an application system needing the change rule, the application system needing the change rule switches the rule, and the new rule is adopted for rule matching.
According to the rule issuing method, the technical means of pre-constructing the rule engine is adopted in the rule changing process, so that the technical problem that the rule matching is forced to pause due to the fact that the project needs to be stopped in the rule changing process in the prior art is solved, the rule is dynamically changed without stopping the project, the technical effect that the rule matching is not paused while the rule is changed is achieved, and the smooth and stable operation of an application system is guaranteed; by constructing the rule issuing center based on the ZooKeeper, the distributed and real-time rule pushing can be conveniently realized; embedding a rule engine jar packet into an application system before the application system is started, and initializing a rule engine after an initial rule is acquired, so that the application system can conveniently perform rule matching according to the transmitted parameters; when the rules are changed, the original rule engine can be continuously adopted to carry out rule matching before the new rule engine which is pre-constructed is not constructed, so that the project does not need to be stopped, and the rule matching does not need to be stopped; the initial rules and the change rules acquired from the rule issuing center are stored to the local of the application system, so that the rules can be still acquired from the local to construct a rule engine in the application system under the condition that the rule issuing center crashes, and the dependency of the application system on the rule issuing center and the rule management center can be reduced; through the mechanism of the layered storage, the pressure of an application system for accessing the rule management center can be reduced to the maximum extent, and the stability of the rule management center is improved; by establishing an application system node in a rule issuing center and registering a monitoring event, when a rule is changed, the changed rule can be acquired in real time; by pre-configuring the rule change strategy in the rule issuing center, the gray level issuing of the rule can be realized according to the rule issuing requirement or the rule engine effective time can be flexibly adjusted according to the actual requirement.
Fig. 6 is a schematic diagram of the main modules of the apparatus for rule change according to the embodiment of the present invention.
As shown in fig. 6, an apparatus 600 for rule modification according to an embodiment of the present invention mainly includes: a pre-construction module 601 and a matching module 602.
The pre-construction module 601 may be configured to pre-construct a new rule engine according to a change rule obtained from a rule issuing center; the matching module 602 may be configured to perform rule matching using the original rule engine before the new rule engine is pre-constructed and perform rule matching using the new rule engine after the new rule engine is pre-constructed.
In the apparatus 600 of the embodiment of the present invention, a rule issuing center may be constructed based on a ZooKeeper server.
Furthermore, the apparatus 600 may further comprise: a rule engine initialization module (not shown in the figure) for embedding the rule engine package before the application system is started; and after the application system is started, initializing a rule engine by using the rule engine package according to the initial rule acquired from the rule issuing center.
The apparatus 600 may further comprise: and a saving module (not shown in the figure) for saving the rule obtained from the rule issuing center to the local.
Additionally, the apparatus 600 may further comprise: a rule monitoring module (not shown in the figure) for establishing an application system node in the rule issuing center and registering a rule change monitoring event on the application system node; and acquiring a change rule which is pushed to the application system node by the rule management center after the rule is changed.
In this embodiment of the present invention, the pre-construction module 601 may further be configured to: and determining the range of the application system server applicable to the new rule engine and/or the effective time of the new rule engine according to a rule change policy pre-configured in the rule issuing center.
From the above description, it can be seen that, because the technical means of pre-constructing the rule engine is adopted in the rule changing process, the technical problem that the project is required to be stopped in the rule changing process in the prior art, so that the rule matching is forced to be stopped is solved, the dynamic change of the rule is further achieved, the project is not required to be stopped, and the technical effect that the rule matching is not stopped while the rule is changed is achieved, so that the smooth and stable operation of an application system is ensured; by constructing the rule issuing center based on the ZooKeeper, the distributed and real-time rule pushing can be conveniently realized; embedding a rule engine jar packet into an application system before the application system is started, and initializing a rule engine after an initial rule is acquired, so that the application system can conveniently perform rule matching according to the transmitted parameters; when the rules are changed, the original rule engine can be continuously adopted to carry out rule matching before the new rule engine which is pre-constructed is not constructed, so that the project does not need to be stopped, and the rule matching does not need to be stopped; the initial rules and the change rules acquired from the rule issuing center are stored to the local of the application system, so that the rules can be still acquired from the local to construct a rule engine in the application system under the condition that the rule issuing center crashes, and the dependency of the application system on the rule issuing center and the rule management center can be reduced; through the mechanism of the layered storage, the pressure of an application system for accessing the rule management center can be reduced to the maximum extent, and the stability of the rule management center is improved; by establishing an application system node in a rule issuing center and registering a monitoring event, when a rule is changed, the changed rule can be acquired in real time; by pre-configuring the rule change strategy in the rule issuing center, the gray level issuing of the rule can be realized according to the rule issuing requirement or the rule engine effective time can be flexibly adjusted according to the actual requirement.
Fig. 7 illustrates an exemplary system architecture 700 to which a rule changing method or a rule changing apparatus of an embodiment of the present invention may be applied.
As shown in fig. 7, the system architecture 700 may include terminal devices 701, 702, 703, a network 704, and a server 705. The network 704 serves to provide a medium for communication links between the terminal devices 701, 702, 703 and the server 705. Network 704 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
A user may use the terminal devices 701, 702, 703 to interact with a server 705 over a network 704, to receive or send messages or the like. The terminal devices 701, 702, 703 may have installed thereon various communication client applications, such as a shopping-like application, a web browser application, a search-like application, an instant messaging tool, a mailbox client, social platform software, etc. (by way of example only).
The terminal devices 701, 702, 703 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 705 may be a server providing various services, such as a background management server (for example only) providing support for shopping websites browsed by users using the terminal devices 701, 702, 703. The backend management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (for example, target push information, product information — just an example) to the terminal device.
It should be noted that the rule changing method provided in the embodiment of the present invention is generally executed by the server 705, and accordingly, the rule changing device is generally installed in the server 705.
It should be understood that the number of terminal devices, networks, and servers in fig. 7 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 8, shown is a block diagram of a computer system 800 suitable for use with a terminal device implementing an embodiment of the present invention. The terminal device shown in fig. 8 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 8, the computer system 800 includes a Central Processing Unit (CPU)801 that can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)802 or a program loaded from a storage section 808 into a Random Access Memory (RAM) 803. In the RAM 803, various programs and data necessary for the operation of the system 800 are also stored. The CPU 801, ROM 802, and RAM 803 are connected to each other via a bus 804. An input/output (I/O) interface 805 is also connected to bus 804.
The following components are connected to the I/O interface 805: an input portion 806 including a keyboard, a mouse, and the like; an output section 807 including a signal such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 808 including a hard disk and the like; and a communication section 809 including a network interface card such as a LAN card, a modem, or the like. The communication section 809 performs communication processing via a network such as the internet. A drive 810 is also connected to the I/O interface 805 as necessary. A removable medium 811 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 810 as necessary, so that a computer program read out therefrom is mounted on the storage section 808 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 809 and/or installed from the removable medium 811. The computer program executes the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 801.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes a pre-build module and a matching module. Where the names of these modules do not in some cases constitute a limitation on the module itself, for example, a pre-build module may also be described as "for pre-building a new rules engine based on change rules obtained from a rules distribution center".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: a new rule engine is pre-constructed according to the change rule acquired from the rule issuing center; and before the new rule engine is pre-constructed, the original rule engine is used for rule matching, and after the new rule engine is pre-constructed, the new rule engine is used for rule matching.
According to the technical scheme of the embodiment of the invention, because the technical means of pre-constructing the rule engine is adopted in the rule changing process, the technical problem that the project is required to be stopped in the rule changing process and the rule matching is forced to be stopped in the prior art is solved, the dynamic changing of the rule is further achieved, the project is not required to be stopped, and the technical effect that the rule matching is not stopped when the rule is changed is achieved, so that the smooth and stable running of an application system is ensured; by constructing the rule issuing center based on the ZooKeeper, the distributed and real-time rule pushing can be conveniently realized; embedding a rule engine jar packet into an application system before the application system is started, and initializing a rule engine after an initial rule is acquired, so that the application system can conveniently perform rule matching according to the transmitted parameters; when the rules are changed, the original rule engine can be continuously adopted to carry out rule matching before the new rule engine which is pre-constructed is not constructed, so that the project does not need to be stopped, and the rule matching does not need to be stopped; the initial rules and the change rules acquired from the rule issuing center are stored to the local of the application system, so that the rules can be still acquired from the local to construct a rule engine in the application system under the condition that the rule issuing center crashes, and the dependency of the application system on the rule issuing center and the rule management center can be reduced; through the mechanism of the layered storage, the pressure of an application system for accessing the rule management center can be reduced to the maximum extent, and the stability of the rule management center is improved; by establishing an application system node in a rule issuing center and registering a monitoring event, when a rule is changed, the changed rule can be acquired in real time; by pre-configuring the rule change strategy in the rule issuing center, the gray level issuing of the rule can be realized according to the rule issuing requirement or the rule engine effective time can be flexibly adjusted according to the actual requirement.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method of rule change, comprising:
a new rule engine is pre-constructed according to the change rule acquired from the rule issuing center;
before the new rule engine is pre-constructed, an original rule engine is used for rule matching, and after the new rule engine is pre-constructed, the new rule engine is used for rule matching;
in the process of pre-constructing a new rule engine according to change rules acquired from a rule issuing center, determining the range of an application system server applicable to the new rule engine and/or the effective time of the new rule engine according to a rule change strategy pre-configured in the rule issuing center;
before pre-building a new rules engine according to change rules obtained from a rules distribution center, the method further comprises:
establishing an application system node in the rule issuing center, and registering a rule change monitoring event on the application system node; and acquiring a change rule which is pushed to the application system node by the rule management center after the rule is changed.
2. The method according to claim 1, wherein the rule issuing center is constructed based on a ZooKeeper server.
3. The method of claim 1, wherein prior to pre-building a new rules engine based on change rules obtained from a rules distribution center, the method further comprises:
embedding a rule engine package before an application system is started; and
and after the application system is started, initializing a rule engine by using the rule engine package according to the initial rule acquired from the rule issuing center.
4. The method according to claim 1 or 3, characterized in that the method further comprises: and storing the rule acquired from the rule issuing center to the local.
5. An apparatus for rule change, comprising:
the pre-construction module is used for pre-constructing a new rule engine according to the change rule acquired from the rule issuing center; determining the range of an application system server applicable to the new rule engine and/or the effective time of the new rule engine according to a rule change strategy pre-configured in the rule issuing center;
the matching module is used for matching the rules by using the original rule engine before the new rule engine is pre-constructed and matching the rules by using the new rule engine after the new rule engine is pre-constructed;
the rule monitoring module is used for establishing an application system node in the rule issuing center and registering a rule change monitoring event on the application system node; and acquiring a change rule which is pushed to the application system node by the rule management center after the rule is changed.
6. The apparatus according to claim 5, wherein the apparatus builds a rule distribution center based on a ZooKeeper server.
7. The apparatus of claim 5, further comprising: the rule engine initialization module is used for embedding a rule engine package before the application system is started; and after the application system is started, initializing a rule engine by using the rule engine package according to the initial rule acquired from the rule issuing center.
8. The apparatus of claim 5 or 7, further comprising: and the storage module is used for storing the rule acquired from the rule issuing center to the local.
9. An electronic device, comprising:
one or more processors;
a storage device to store one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-4.
10. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-4.
CN201711103749.9A 2017-11-10 2017-11-10 Method and device for rule change Active CN109783151B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711103749.9A CN109783151B (en) 2017-11-10 2017-11-10 Method and device for rule change

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711103749.9A CN109783151B (en) 2017-11-10 2017-11-10 Method and device for rule change

Publications (2)

Publication Number Publication Date
CN109783151A CN109783151A (en) 2019-05-21
CN109783151B true CN109783151B (en) 2022-07-05

Family

ID=66484424

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711103749.9A Active CN109783151B (en) 2017-11-10 2017-11-10 Method and device for rule change

Country Status (1)

Country Link
CN (1) CN109783151B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110297859B (en) * 2019-06-10 2021-07-06 恩亿科(北京)数据科技有限公司 Method and apparatus for processing real-time data
CN111767157A (en) * 2019-08-07 2020-10-13 北京京东尚科信息技术有限公司 Request processing method and device based on service grid
CN111639084A (en) * 2020-04-10 2020-09-08 深圳市华智有为科技有限公司 Dynamic rule generation method and system, application terminal and management terminal
CN112988277B (en) * 2021-03-31 2023-06-30 建信金融科技有限责任公司 Rule file loading method, device, server and medium
CN112799647B (en) * 2021-04-12 2021-11-23 四川新网银行股份有限公司 Business personnel-oriented rule engine adapter device identification method
CN113341757A (en) * 2021-07-02 2021-09-03 佛山市淇特科技有限公司 Smart home equipment linkage method, device, equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104536325A (en) * 2014-12-31 2015-04-22 西安诺瓦电子科技有限公司 Method and device for determining LED control system strategy
CN105426748A (en) * 2014-09-18 2016-03-23 腾讯科技(深圳)有限公司 Rule file updating method and device
CN105656989A (en) * 2015-12-10 2016-06-08 天津海量信息技术有限公司 Distributed computing method based on hive mind
CN106372778A (en) * 2016-08-23 2017-02-01 江苏亿科达科技发展有限公司 Vehicle scheduling system and method based on dynamic rule engine
CN107133039A (en) * 2017-04-28 2017-09-05 九次方大数据信息集团有限公司 The construction method and device of regulation engine

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105426748A (en) * 2014-09-18 2016-03-23 腾讯科技(深圳)有限公司 Rule file updating method and device
CN104536325A (en) * 2014-12-31 2015-04-22 西安诺瓦电子科技有限公司 Method and device for determining LED control system strategy
CN105656989A (en) * 2015-12-10 2016-06-08 天津海量信息技术有限公司 Distributed computing method based on hive mind
CN106372778A (en) * 2016-08-23 2017-02-01 江苏亿科达科技发展有限公司 Vehicle scheduling system and method based on dynamic rule engine
CN107133039A (en) * 2017-04-28 2017-09-05 九次方大数据信息集团有限公司 The construction method and device of regulation engine

Also Published As

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

Similar Documents

Publication Publication Date Title
CN109783151B (en) Method and device for rule change
WO2020177533A1 (en) Electronic invoice identifier allocation method, and electronic ticket generating method, device and system
US8396961B2 (en) Dynamic control of transaction timeout periods
CN113254466B (en) Data processing method and device, electronic equipment and storage medium
CN109245908B (en) Method and device for switching master cluster and slave cluster
CN110120961B (en) Distributed service cluster and route synchronization method thereof
US11656902B2 (en) Distributed container image construction scheduling system and method
CN110351366A (en) A kind of service scheduling method of Internet application, system and computer readable storage medium
CN108712457A (en) Back-end server dynamic load method of adjustment and device based on Nginx reverse proxys
CN111258627A (en) Interface document generation method and device
CN113127732A (en) Method and device for acquiring service data, computer equipment and storage medium
CN111338834B (en) Data storage method and device
CN113079098B (en) Method, device, equipment and computer readable medium for updating route
CN108874531B (en) Method, device and system for fusing service and electronic equipment
CN111597033A (en) Task scheduling method and device
CN112187916B (en) Cross-system data synchronization method and device
CN114760360B (en) Request response method, request response device, electronic equipment and computer readable storage medium
CN115686813A (en) Resource scheduling method and device, electronic equipment and storage medium
CN112559001B (en) Method and device for updating application
CN110661857B (en) Data synchronization method and device
CN113296968A (en) Address list updating method, device, medium and electronic equipment
US20200272453A1 (en) Real-Time Version Controller
CN112749042B (en) Application running method and device
CN113259431B (en) Service calling method, service calling device, electronic device and storage medium
CN112994894B (en) Gateway-based single-thread request processing method and information verification AGENT

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