CN111488179A - Rule system and construction method thereof, business system and application method thereof - Google Patents

Rule system and construction method thereof, business system and application method thereof Download PDF

Info

Publication number
CN111488179A
CN111488179A CN201910078085.8A CN201910078085A CN111488179A CN 111488179 A CN111488179 A CN 111488179A CN 201910078085 A CN201910078085 A CN 201910078085A CN 111488179 A CN111488179 A CN 111488179A
Authority
CN
China
Prior art keywords
rule
memory
cache
business
loading
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.)
Pending
Application number
CN201910078085.8A
Other languages
Chinese (zh)
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.)
Shanghai Bilibili Technology Co Ltd
Original Assignee
Shanghai Bilibili 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 Shanghai Bilibili Technology Co Ltd filed Critical Shanghai Bilibili Technology Co Ltd
Priority to CN201910078085.8A priority Critical patent/CN111488179A/en
Publication of CN111488179A publication Critical patent/CN111488179A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0238Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory
    • G06F12/0246Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory in block erasable memory, e.g. flash memory

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Devices For Executing Special Programs (AREA)

Abstract

The invention relates to a rule system and a construction method thereof, and a business system based on the rule system and an application method thereof, belonging to the technical field of Internet. By adopting the rule system, the rule loader initiates a loading task at regular time, loads the rule from the cache, obtains the rule from the database if no corresponding rule exists in the cache, translates the rule into the rule grammar by the rule translator, compiles the rule grammar and loads the rule grammar into the memory to form a rule set. When a business system sends out a rule execution request, the rule system can acquire and execute a corresponding rule from a rule set of a local memory, so that rule application can be realized based on page operation, the service rule system use threshold of non-technical personnel is greatly reduced, and meanwhile, the local file loading is avoided, so that the rule execution efficiency under a high concurrent environment is effectively ensured, and the performance and the availability of the system are improved.

Description

Rule system and construction method thereof, business system and application method thereof
Technical Field
The invention relates to the technical field of internet, in particular to the technical field of enterprise rule systems, and specifically relates to a rule system and a construction method thereof, and a business system based on the rule system and an application method thereof.
Background
Most of the existing enterprise realization rule systems are based on a drools rule engine under JBOSS flags, the engine is based on a reteOO algorithm, the decision process of rules is optimized, and particularly, under a large number of rules, service codes are greatly simplified.
However, the drl file and excel file configuration modes supported by the rule engine are not high in practicability. The former is a script file with java grammar, and the use threshold of non-service personnel is higher. The latter format is complicated and is prone to errors. And both of them need to load local files, and the efficiency of rule execution is difficult to ensure in a high concurrency environment, thereby causing misjudgment of services.
Therefore, how to provide a rule system that can reduce the service rule system usage threshold of non-technical personnel, ensure the rule execution efficiency in a high concurrency environment, and improve the performance and availability of the system becomes a problem to be solved in the field.
Disclosure of Invention
The present invention is directed to overcome the above disadvantages in the prior art, and provides a rule system and a method for constructing the same, and a business system and a method for applying the same, which can be implemented based on page operations, reduce the service rule system usage threshold of non-technical personnel, ensure the rule execution efficiency in a high concurrency environment, and improve the performance and availability of the system.
In order to achieve the above object, the method for constructing a rule system of the present invention includes the steps of:
(1) the rule loader initiates a loading task at regular time and loads the rule from the cache;
(2) judging whether the cache has a rule to be loaded, if so, entering the step (4); if not, entering the step (3);
(3) inquiring a database and feeding back a rule set corresponding to the loading task to the cache;
(4) feeding back a rule set corresponding to the loading task to the rule loader;
(5) the rule translator translates the rule set into a rule grammar and compiles the rule grammar to form a rule engine knowledge base;
(6) and loading the compiling rules in the rule engine knowledge base into a memory, and forming a rule set in the memory.
In the rule system construction method, the cache is a centralized memory cache server.
In the rule system construction method, the memory is a local memory of the rule system.
The present invention also provides a rule system, comprising:
the rule loader is used for initiating a loading task at regular time and loading the rule from the cache;
the cache is used for storing the rule set, judging whether the rule set required to be loaded exists in the cache after receiving the loading task, and directly feeding back the rule set corresponding to the loading task to the rule loader if the rule set required to be loaded exists in the cache; if not, inquiring a database, and feeding back a rule set which is obtained from the database and corresponds to the loading task to the rule loader;
the rule translator is used for acquiring the loaded rule set from the rule loader, translating the rule set into rule grammar and compiling to form a rule engine knowledge base;
and the memory is used for loading the compiling rules in the rule engine knowledge base to form a rule set.
In the rule system, the cache is a centralized memory cache server.
In the rule system, the memory is a local memory of the rule system.
The invention also discloses a business system application method, which comprises the following steps:
(A) the business system calls a rule execution interface between the business system and the rule system and initiates a business execution request to the rule system;
(B) the rule system acquires a rule corresponding to the service execution request from the rule set of the memory;
(C) the rule system executes the acquired rule to generate an execution result;
(D) and the rule feeds back the execution result to the service system.
In the service system application method, the step (a) is specifically as follows:
based on page operation, calling a rule execution interface between a business system and a rule system, and initiating a business execution request to the rule system.
In the service system application method, the step (B) specifically includes the following steps:
(B1) the rule system sends out a session (session) to the memory according to the service execution request;
(B2) and the memory feeds back all rules required by the service execution request to the rule system according to the execution session.
In the service system application method, the memory is a local memory of the rule system.
The invention also provides a service system for realizing the service system application method.
By adopting the rule system and the construction method thereof as well as the business system based on the rule system and the application method thereof, in the rule system, the rule loader initiates a loading task at regular time, loads the rule from the cache, if the cache does not have the corresponding rule, the rule is acquired from the database, then the rule is translated into the rule grammar by the rule translator, and the rule grammar is compiled and loaded into the memory to form the rule set. When a business system sends out a rule execution request, the rule system can acquire and execute corresponding rules from a rule set of a local memory, so that rule application can be realized based on page operation, the service rule system use threshold of non-technical personnel is greatly reduced, and meanwhile, the loading of a local file is avoided, so that the rule execution efficiency under a high concurrent environment is effectively ensured, and the performance and the availability of the system are improved.
Drawings
FIG. 1 is a flow chart of the steps of a rule system construction method of the present invention.
Fig. 2 is a flowchart of steps of a business system application method of the present invention.
FIG. 3 is a timing diagram of the rule system and business system of the present invention in practical application.
Detailed Description
In order to clearly understand the technical contents of the present invention, the following examples are given in detail.
Please refer to fig. 1, which is a flowchart illustrating a method for constructing a rule system according to the present invention.
In one embodiment, the rule system construction method comprises the following steps:
(1) the rule loader initiates a loading task at regular time and loads the rule from the cache;
(2) judging whether the cache has a rule to be loaded, if so, entering the step (4); if not, entering the step (3);
(3) inquiring a database and feeding back a rule set corresponding to the loading task to the cache;
(4) feeding back a rule set corresponding to the loading task to the rule loader;
(5) the rule translator translates the rule set into a rule grammar and compiles the rule grammar to form a rule engine knowledge base;
(6) and loading the compiling rules in the rule engine knowledge base into a memory, and forming a rule set in the memory.
In a preferred embodiment, the database is a Mysql database or an Oracle database, the cache is a centralized memory cache server, such as Redis, Memcache, or the like, and the memory is a local memory of the rule system, such as guava cache, or the like.
The present invention also provides a rule system that, in one embodiment, includes: rule loader, rule translator, cache and memory.
The rule loader is used for initiating a loading task at regular time and loading the rule from the cache. The cache is used for storing the rule set, judging whether the rule set required to be loaded exists in the cache after receiving the loading task, and directly feeding back the rule set corresponding to the loading task to the rule loader if the rule set required to be loaded exists in the cache; and if not, inquiring a database, and feeding back a rule set which is obtained from the database and corresponds to the loading task to the rule loader. The rule translator is used for acquiring the loaded rule set from the rule loader, translating the rule set into rule grammar and compiling to form a rule engine knowledge base. The memory is used for loading the compiling rules in the rule engine knowledge base to form a rule set.
In a preferred embodiment, the database is a Mysql database or an Oracle database, the cache is a centralized memory cache server, such as Redis, Memcache, or the like, and the memory is a local memory of the rule system, such as guava cache, or the like.
The present invention also provides a business system application method, as shown in fig. 2, the application method includes the following steps:
(A) the business system calls a rule execution interface between the business system and the rule system and initiates a business execution request to the rule system;
(B) the rule system acquires a rule corresponding to the service execution request from the rule set of the memory;
(C) the rule system executes the acquired rule to generate an execution result;
(D) and the rule feeds back the execution result to the service system.
The memory is a local memory of the rule system, such as a guava cache.
In a preferred embodiment, the step (a) is specifically:
based on page operation, calling a rule execution interface between a service system and a rule system, and sending a service execution request to the rule system, wherein the service system can realize rule configuration based on an E L expression.
In another preferred embodiment, the step (B) specifically comprises the following steps:
(B1) the rule system sends out an execution session to the memory according to the service execution request;
(B2) and the memory feeds back all rules required by the service execution request to the rule system according to the execution session.
The invention also provides a service system for realizing the service system application method.
In practical application, the invention aims to provide a rule system which can be realized based on page operation, E L expression syntax configuration and asynchronous loading mode, and a timing chart of the rule system and a corresponding business system in practical application is shown in FIG. 3.
The following examples illustrate the practical implementation of the present invention.
Example 1
The rule system is based on a drools engine
The main components for realizing the functions of the system comprise: drools rule engines, databases (e.g., Mysql, Oracle), centralized memory caching services (e.g., Redis, Memcache), and local memory caching (e.g., guava cache, etc.).
The overall execution logic of the system is as follows:
1) the rule loader reads the rules from the centralized memory cache service at regular time, invokes the rule interpreter, translates the rules into a compilable rule grammar and compiles the rules into a rule engine knowledge base of the local memory cache.
2) If no rule exists in the cache, the database (such as Mysql, Oracle and the like) is directly read, the result set is stored in a centralized memory cache service, and then translation and compilation are carried out to be stored in the rule engine knowledge base.
3) When a rule execution request exists, the business system creates an execution environment, an execution instruction is sent to the rule system, the rule system directly executes a rule set in the knowledge base, and a result is fed back to the business system.
Example 2
Taking the payment wind control platform as an example,
and an operator configures rules on a background page, and the rule loader can read the rules into the cache at regular time and load the rules into the local memory after the rules are translated by the rule interpreter.
The method comprises the steps that a user makes order payment at an app/pc end, a payment request is submitted to a payment system through a service system, the payment system is asynchronously submitted to a wind control system, the wind control system starts a rule core after receiving the request, an operating environment is directly created based on a local memory rule set, and after rules are executed in batches, wind control results are asynchronously called back to the payment system.
The rule core uses the rule system of the invention, under the configuration of hundreds of rules, the time consumption of rule execution can be controlled to be less than 10ms, and a service system is supported efficiently; and by matching with the page of the management background, the wind control rule making personnel can conveniently and efficiently configure the modification rule without issuing restarting service.
Compared with the prior art, the invention mainly has the following four beneficial effects:
1. the rule execution efficiency is improved, and under the condition of hundreds of rules and the same request peak value, the execution efficiency is improved by 10-20 times.
2. The time consumption of the business calling rule system is reduced, and the execution environment can be directly obtained when the rule is actually executed due to asynchronous loading and compiling of the rule base.
3. The use threshold of rule making personnel is reduced, rule conditions and configuration thresholds can be conveniently selected on the page, and the original rule configuration mode of writing codes or maintaining excel is abandoned.
4. The efficiency of rule online and offline is improved, the original steps of modifying rule files and releasing the rule files to be online are changed into the step of modifying the state in the database, the system release amount is reduced, and the system availability is improved.
By adopting the rule system and the construction method thereof as well as the business system based on the rule system and the application method thereof, in the rule system, the rule loader initiates a loading task at regular time, loads the rule from the cache, if the cache does not have the corresponding rule, the rule is acquired from the database, then the rule is translated into the rule grammar by the rule translator, and the rule grammar is compiled and loaded into the memory to form the rule set. When a business system sends out a rule execution request, the rule system can acquire and execute corresponding rules from a rule set of a local memory, so that rule application can be realized based on page operation, the service rule system use threshold of non-technical personnel is greatly reduced, and meanwhile, the loading of a local file is avoided, so that the rule execution efficiency under a high concurrent environment is effectively ensured, and the performance and the availability of the system are improved.
In this specification, the invention has been described with reference to specific embodiments thereof. It will, however, be evident that various modifications and changes may be made thereto without departing from the broader spirit and scope of the invention. The specification and drawings are, accordingly, to be regarded in an illustrative rather than a restrictive sense.

Claims (11)

1. A rule system construction method is characterized by comprising the following steps:
(1) the rule loader initiates a loading task at regular time and loads the rule from the cache;
(2) judging whether the cache has a rule to be loaded, if so, entering the step (4); if not, entering the step (3);
(3) inquiring a database and feeding back a rule set corresponding to the loading task to the cache;
(4) feeding back a rule set corresponding to the loading task to the rule loader;
(5) the rule translator translates the rule set into a rule grammar and compiles the rule grammar to form a rule engine knowledge base;
(6) and loading the compiling rules in the rule engine knowledge base into a memory, and forming a rule set in the memory.
2. The method according to claim 1, wherein the cache is a centralized memory cache server.
3. The method according to claim 1, wherein the memory is a local memory of the rule system.
4. A rule system, comprising:
the rule loader is used for initiating a loading task at regular time and loading the rule from the cache;
the cache is used for storing the rule set, judging whether the rule set required to be loaded exists in the cache after receiving the loading task, and directly feeding back the rule set corresponding to the loading task to the rule loader if the rule set required to be loaded exists in the cache; if not, inquiring a database, and feeding back a rule set which is obtained from the database and corresponds to the loading task to the rule loader;
the rule translator is used for acquiring the loaded rule set from the rule loader, translating the rule set into rule grammar and compiling to form a rule engine knowledge base;
and the memory is used for loading the compiling rules in the rule engine knowledge base to form a rule set.
5. The algorithm as claimed in claim 4, wherein the cache is a centralized in-memory cache server.
6. The algorithm of claim 4, wherein the memory is a local memory of the algorithm.
7. A business system application method is characterized in that the application method comprises the following steps:
(A) the business system calls a rule execution interface between the business system and the rule system and initiates a business execution request to the rule system;
(B) the rule system acquires a rule corresponding to the service execution request from the rule set of the memory;
(C) the rule system executes the acquired rule to generate an execution result;
(D) the rule feeds back the execution result to the service system;
wherein the rule system is the rule system of claim 4.
8. The business system application method of claim 7, wherein the step (A) is specifically as follows:
based on page operation, calling a rule execution interface between a business system and a rule system, and initiating a business execution request to the rule system.
9. The business system application method of claim 7, wherein the step (B) comprises the steps of:
(B1) the rule system sends out an execution session to the memory according to the service execution request;
(B2) and the memory feeds back all rules required by the service execution request to the rule system according to the execution session.
10. The business system application method of claim 9, wherein the memory is a local memory of the rule system.
11. A business system for implementing the business system application method of any one of claims 7 to 10.
CN201910078085.8A 2019-01-28 2019-01-28 Rule system and construction method thereof, business system and application method thereof Pending CN111488179A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910078085.8A CN111488179A (en) 2019-01-28 2019-01-28 Rule system and construction method thereof, business system and application method thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910078085.8A CN111488179A (en) 2019-01-28 2019-01-28 Rule system and construction method thereof, business system and application method thereof

Publications (1)

Publication Number Publication Date
CN111488179A true CN111488179A (en) 2020-08-04

Family

ID=71812314

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910078085.8A Pending CN111488179A (en) 2019-01-28 2019-01-28 Rule system and construction method thereof, business system and application method thereof

Country Status (1)

Country Link
CN (1) CN111488179A (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101056210A (en) * 2007-06-05 2007-10-17 网御神州科技(北京)有限公司 An event processing system and method of network central management platform
CN102542382A (en) * 2010-12-14 2012-07-04 ***通信集团贵州有限公司 Method and device for managing business rule
CN103870308A (en) * 2012-12-13 2014-06-18 杭州勒卡斯广告策划有限公司 Data processing method and device
CN105684391A (en) * 2013-11-04 2016-06-15 伊尔拉米公司 Automated generation of label-based access control rules
CN106101090A (en) * 2016-06-07 2016-11-09 中国建设银行股份有限公司 Operational approach and rule engine system for regulation engine
CN106559404A (en) * 2015-09-30 2017-04-05 北京奇虎科技有限公司 A kind of client for accessing data, proxy server and system
CN108090153A (en) * 2017-12-11 2018-05-29 深圳云天励飞技术有限公司 A kind of searching method, device, electronic equipment and storage medium
CN108376064A (en) * 2016-11-24 2018-08-07 阿里巴巴集团控股有限公司 The correlation technique of rule engine system and regulation engine
CN108874304A (en) * 2018-03-30 2018-11-23 北京奇艺世纪科技有限公司 A kind of regular configuration method and device of caching system

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101056210A (en) * 2007-06-05 2007-10-17 网御神州科技(北京)有限公司 An event processing system and method of network central management platform
CN102542382A (en) * 2010-12-14 2012-07-04 ***通信集团贵州有限公司 Method and device for managing business rule
CN103870308A (en) * 2012-12-13 2014-06-18 杭州勒卡斯广告策划有限公司 Data processing method and device
CN105684391A (en) * 2013-11-04 2016-06-15 伊尔拉米公司 Automated generation of label-based access control rules
CN106559404A (en) * 2015-09-30 2017-04-05 北京奇虎科技有限公司 A kind of client for accessing data, proxy server and system
CN106101090A (en) * 2016-06-07 2016-11-09 中国建设银行股份有限公司 Operational approach and rule engine system for regulation engine
CN108376064A (en) * 2016-11-24 2018-08-07 阿里巴巴集团控股有限公司 The correlation technique of rule engine system and regulation engine
CN108090153A (en) * 2017-12-11 2018-05-29 深圳云天励飞技术有限公司 A kind of searching method, device, electronic equipment and storage medium
CN108874304A (en) * 2018-03-30 2018-11-23 北京奇艺世纪科技有限公司 A kind of regular configuration method and device of caching system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
,胡继阳,李维仁,柯力群,张志龙: "《高校数据仓库***建设与应用》", 北京:中国铁道出版社, pages: 222 *

Similar Documents

Publication Publication Date Title
CN102187313B (en) Caching runtime generated code
CN101930400B (en) SDK (Software Development Kit) automatic test system and method
CN111581948B (en) Document analysis method, device, equipment and storage medium
CN111625224A (en) Code generation method, device, equipment and storage medium
US20140033208A1 (en) Method and device for loading application program
CN110109671B (en) Webpack label size and style conversion method and device
CN107391130B (en) API automatic management and SDK, document automatic generation method
CN111324619B (en) Object updating method, device, equipment and storage medium in micro-service system
CN111596970B (en) Method, device, equipment and storage medium for dynamic library delay loading
CN113609101A (en) Real-time data task issuing method and device, electronic equipment and storage medium
KR20210040322A (en) Scheduling method and apparatus, device and storage medium
CN110457013B (en) Program component configuration device and method
CN114115884A (en) Management method and related device for programming service
CN111488179A (en) Rule system and construction method thereof, business system and application method thereof
CN101561884B (en) Method and device for achieving script in variable data printing process
CN110750310A (en) Binary and source code switching method based on IOS system componentization development
CN113626071B (en) Function registration method, system, electronic device and storage medium
CN115268909A (en) Method, system and terminal for establishing and running construction task at web front end
CN115022312A (en) Method and device for realizing multiple intelligent contract engines, electronic equipment and storage medium
CN109857380B (en) Workflow file compiling method and device
CN109857390B (en) Annotation transmission method of Git warehouse file annotation system
CN112114817A (en) COBOL language-based data dictionary field information acquisition method and device
CN108694046B (en) Container assembly method and apparatus
CN106681914B (en) Television picture quality debugging method and device
CN111104161A (en) Automatic approval execution method for database sql script

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