CN114490694A - Business rule processing method and device, server and storage medium - Google Patents

Business rule processing method and device, server and storage medium Download PDF

Info

Publication number
CN114490694A
CN114490694A CN202210152223.4A CN202210152223A CN114490694A CN 114490694 A CN114490694 A CN 114490694A CN 202210152223 A CN202210152223 A CN 202210152223A CN 114490694 A CN114490694 A CN 114490694A
Authority
CN
China
Prior art keywords
rule
preset
file
storage medium
service
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
CN202210152223.4A
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.)
Jiqi Chengdu Technology Co ltd
Original Assignee
Jiqi Chengdu 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 Jiqi Chengdu Technology Co ltd filed Critical Jiqi Chengdu Technology Co ltd
Priority to CN202210152223.4A priority Critical patent/CN114490694A/en
Publication of CN114490694A publication Critical patent/CN114490694A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2379Updates performed during online database operations; commit processing
    • 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/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • 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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • 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/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • GPHYSICS
    • G16INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR SPECIFIC APPLICATION FIELDS
    • G16YINFORMATION AND COMMUNICATION TECHNOLOGY SPECIALLY ADAPTED FOR THE INTERNET OF THINGS [IoT]
    • G16Y40/00IoT characterised by the purpose of the information processing
    • G16Y40/30Control
    • G16Y40/35Management of things, i.e. controlling in accordance with a policy or in order to achieve specified objectives

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Business, Economics & Management (AREA)
  • General Business, Economics & Management (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention provides a method, a device, a server and a storage medium for processing a business rule, which relate to the field of data processing, and the method comprises the following steps: acquiring a rule file of a preset service from a preset physical storage medium; initializing the rule file into a rule management model of a preset rule engine according to the rule file; and writing the rule management model containing the rule file into a memory of a preset rule engine to obtain a rule container of the preset service, wherein the rule container is used for executing the rule data in the rule file on the service data of the preset service. By adopting the invention, the lossy shutdown caused by the processing of the business rules can be avoided, and the processing efficiency of the business rules is accelerated.

Description

Business rule processing method and device, server and storage medium
Technical Field
The present invention relates to the field of data processing, and in particular, to a method, an apparatus, a server, and a storage medium for processing a business rule.
Background
The technology of the internet of things serves as the basis of intelligent management of the equipment, interaction of different types of equipment through a network is promoted, and technical support is provided for building a management platform of the internet of things.
When the internet of things management is performed, the rule engines are used more and more frequently, but in a common rule engine service scheme, when rules are newly added or updated, not only is the equipment required to perform lossy shutdown, but also no user interaction interface is provided for business personnel to perform rule maintenance, so that the normal use of users is inevitably influenced by the rules which change frequently in the actual business.
Therefore, each time a new service is required, the new service cannot be updated in time, and heavy communication cost between service personnel and research and development personnel is also increased.
Disclosure of Invention
The business rule processing method, the business rule processing device, the server and the storage medium provided by the embodiment of the invention can avoid the lossy shutdown caused by the business rule processing and accelerate the processing efficiency of the business rule.
In a first aspect, an embodiment of the present invention provides a method for processing a business rule, where the method includes:
acquiring a rule file of a preset service from a preset physical storage medium;
initializing the rule file into a rule management model of a preset rule engine according to the rule file;
writing the rule management model containing the rule file into a memory of the preset rule engine to obtain a rule container of the preset service, wherein the rule container is used for executing the rule data in the rule file on the service data of the preset service.
Optionally, the obtaining a rule file of a preset service from a preset physical storage medium includes:
and when the preset rule engine is started, all rule files of the preset service are acquired from the physical storage medium.
Optionally, the obtaining a rule file of a preset service from a preset physical storage medium includes:
and if the rule reloading operation triggered by the preset rule reloading interface is detected, acquiring a first rule file reloaded by the rule reloading interface from the physical storage medium.
Optionally, the obtaining a rule file of a preset service from a preset physical storage medium includes:
acquiring the rule data input by a user through a rule management interface;
generating the rule file by adopting a preset conversion rule according to the rule data;
and calling a preset rule management interface, and writing the rule file into the physical storage medium.
Optionally, the invoking a preset rule management interface, and writing the rule data into the physical storage medium includes:
and calling a preset rule writing interface, and writing the rule file into the rule data and writing the rule data into the physical storage medium.
Optionally, the invoking a preset rule writing interface, writing the rule file into the rule data and writing the rule data into the physical storage medium, includes:
and calling the rule writing interface according to at least one storage drive, and respectively writing the rule file into the physical storage medium corresponding to the at least one storage drive.
Optionally, the method further comprises:
if a rule triggering request triggered by a preset rule triggering interface is detected, inquiring a rule container associated with a second rule file triggered by the rule triggering interface from the preset memory;
and executing the rule data in the second rule file on the service data by adopting the rule container associated with the second rule file.
In a second aspect, an embodiment of the present invention further provides a device for processing a business rule, where the device includes:
the acquisition module is used for acquiring the rule file of the preset service from a preset physical storage medium;
the initialization module is used for initializing the rule file into a rule management model of a preset rule engine according to the rule file;
and the processing module is used for writing the rule management model containing the rule file into a memory of the preset rule engine to obtain a rule container of the preset service, and the rule container is used for executing the rule data in the rule file on the service data of the preset service.
In a third aspect, an embodiment of the present invention further provides a service rule processing server, where the service rule processing server includes: a processor, a memory and a bus, the processor and the memory are connected by the bus, the memory stores program instructions executable by the processor, and when the business rule processing server runs, the processor executes the program instructions to execute the steps of the business rule processing method according to any one of the first aspect.
In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, where the storage medium stores a computer program, and the computer program is executed by a processor to perform the steps of the business rule processing method according to any one of the first aspect.
According to the business rule processing method, the business rule processing device, the server and the storage medium, the physical storage medium is used for storing the rule file, so that the rule file of related business can be directly obtained from the preset physical storage medium when the business rule processing is carried out, the rule file can be initialized to the rule management model of the preset rule engine according to the rule file, the rule management model containing the rule file is written into the memory of the preset rule engine, the rule container of the preset business is finally obtained, and the business data can be executed to the rule data in the rule file in the container. By the service rule processing method, the rule file is directly called in the physical storage medium, the whole service project does not need to be paused, the service rule processing is performed in the rule container, the whole service project can be normally used without restarting after the processing is completed, service personnel can perform the service rule processing conveniently, the service personnel and technical personnel can quickly reach the consistency, the whole service rule processing is more flexible, the destructive shutdown caused by the service rule processing is avoided, the processing efficiency of the service rule is accelerated, the service personnel is helped to realize the self-maintenance of the service, and the maintenance cost and the updating period are greatly reduced.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
Fig. 1 is a schematic flow diagram of a business rule processing method according to the present invention;
fig. 2 is a schematic flow chart of a rule writing method in a business rule processing method according to the present invention;
FIG. 3 is a schematic diagram of a business rule management interface according to the present invention;
FIG. 4 is a schematic diagram of a process of generating business rules in business rule processing according to the present invention;
FIG. 5 is a flowchart illustrating a rule triggering method in a business rule processing according to the present invention;
FIG. 6 is a schematic diagram of a business rule processing apparatus according to the present invention;
fig. 7 is a schematic diagram of a business rule processing server according to the present invention.
Icon: 1000, obtaining a module; 2000, initializing the module; 3000, a processing module; 10, a business rule processing server; 11, a processor; 12, a memory; 13, a bus.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
Before explaining the present invention in detail, an application scenario of the present invention will be described.
In the embodiment of the present invention, implementation is performed based on a related technology of a Drools rule engine of a Rete algorithm, and a preliminary description is provided here:
drools: drools is a Java language based, open source rule engine. The rule engine independently provides a set of API interface for processing the business logic from the business layer, thereby realizing the complete decoupling of the rule logic and the business system.
Rete: the Rete algorithm is an efficient pattern matching algorithm, is the most widely used rule matching algorithm at present, can realize efficient matching of pattern set and object set comparison, and finds out all objects and rules matching each pattern through network screening.
A rule engine: the rule engine is an embedded application component developed by the inference engine, which separates the business decision rule from the application code, and the actual business decision can be expressed by using the semantic module defined by the rule engine. After entering the relevant data into the rules engine, the rules engine interprets the rules and makes corresponding decisions.
The explosive growth of the internet of things has the problem that for a project, a plurality of new services are brought on line and updated daily. From project networking, data reporting, instruction execution, to change of project state, any link is very critical to the whole life cycle of the project, and complex event processing is required. Most complex event processing applications require business rules to be updated according to business requirements, and in order to achieve this, business personnel are required to be able to directly manage the rules of the system without the involvement of developers. Numerous rules engines have been derived based on this need. The rule engine is a component embedded in a complex event processing type application program and is mainly used for realizing the separation function of decision logic and a business system, wherein the Drools rule engine based on the Rete algorithm is a rule engine service which is relatively commonly used at present.
However, Drools can only identify and process business logic defined based on a specific format, that is, business personnel cannot directly define business logic meeting actual needs, and technical personnel are needed to complete the business logic; once the rules change, a great deal of communication and coordination work needs to be carried out between business personnel and professionals, so that the execution efficiency of the rule engine in the whole system is greatly reduced.
Meanwhile, under the traditional business processing method, the rule data are stored in the memory, once the rule changes, the operation of the server needs to be stopped to modify the business data, but the server is restarted frequently, so that the server is unstable, and a large amount of server resources are occupied.
Based on this, the invention provides a method, an apparatus, a server and a storage medium for processing a business rule, which can directly obtain a rule file of a related business from a preset physical storage medium when a business rule is processed by using the physical storage medium to store the rule file, initialize the rule file to a rule management model of a preset rule engine according to the rule file, write the rule management model containing the rule file into a memory of the preset rule engine, and finally obtain a rule container of the preset business, i.e. execute the rule data in the rule file by using the business data in the container. The service rule processing method provided in the following embodiments of the present invention may be executed by a service rule processing server, which may be, for example, a mobile communication device or a desktop computer device, and the present invention is not limited thereto.
The following is an explanation by way of various embodiments in conjunction with the accompanying drawings. Fig. 1 is a schematic flow diagram of a service rule processing method provided by the present invention, and as shown in fig. 1, the service rule processing method includes:
and S110, acquiring a rule file of a preset service from a preset physical storage medium.
The Drools rules engine provides an KIE system for visual configuration editing management that can maintain required rule files in a rule file format supported by the rules engine to strip rule file data from the business system. The embodiment is implemented based on a Drools-Springboot framework, and the whole framework is divided into three layers, wherein one layer is a rule service interface layer and is used for providing an interface called externally; one layer is a rule service management logic layer and is used for processing business logic; one layer is the Drools rules engine layer, encapsulating the interfaces provided by the various Drools rules engines.
Specifically, a rule file of a preset service is acquired from a preset physical storage medium at a rule service management logic layer. The preset physical storage medium includes a storage medium such as a file system, a database, a remote data service, and the like, which is not limited in the present invention. When the rule file of the preset service is obtained, the corresponding storage medium can be selected from the preset physical storage media according to the preset to call the rule file corresponding to the preset service.
And S120, initializing the rule file into a rule management model of a preset rule engine according to the rule file.
After the rule file of the preset service is obtained, initializing and constructing a Drools rule engine. In this embodiment, the tool class kieserices may be initialized first. The kieserices class is the core functional class of the rules engine that provides many ways in which the running related objects can be accessed KIE. And then initializing the rule file into a rule management model of a preset rule engine according to the rule file. Specifically, KieBase, kiemolle and Rules can be sequentially constructed according to the rule file, and the currently initialized kiemolemodel includes the rule file corresponding to the preset service in the rule management model of the preset rule engine.
S130, writing the rule management model containing the rule file into a memory of a preset rule engine to obtain a rule container of the preset service.
The rule container is used for executing the rule data in the rule file on the service data of the preset service.
And after the initialization of the rule management model of the preset rule engine is finished, continuously initializing the memory of the preset rule engine. After the initialization of the memory of the preset rule engine is completed, writing the rule management model of the preset rule engine containing the rule file into the memory of the preset rule engine to obtain a rule container of the preset service. Specifically, the related file of the kiemolemodel is written into a memory file system kiefile system of the Drools rule engine, so that the initialized kiecondainer can be obtained. And the rule data in the rule file can be executed on the service data of the preset service in the KieContainer, and the rule data can be stored after initialization is finished without restarting a server.
In a possible implementation manner, when executing rules for business data in a container, if multiple rules conflict in execution at the same time, the execution order of the conflicting rules is managed by the agenda.
According to the business rule processing method, the rule file is directly called in the physical storage medium, the whole business project does not need to be paused, the business rule processing is carried out in the rule container, the whole business project can be normally used without restarting after the processing is completed, business personnel can carry out the business rule processing conveniently, the business personnel and technical personnel can quickly reach the consistency, the whole business rule processing is more flexible, the destructive shutdown caused by the business rule processing is avoided, the processing efficiency of the business rule is improved, the business personnel are helped to realize the self-maintenance of the business, and the maintenance cost and the updating period are greatly reduced.
On the basis of the service rule processing method provided in fig. 1, in the step S110, acquiring a rule file of a preset service from a preset physical storage medium includes:
s210, when the preset rule engine is started, all rule files of the preset service are obtained from the physical storage medium.
In a specific implementation process, all rule files of a preset service need to be acquired from a physical storage medium when a preset rule engine is started. Specifically, after the Drools rule engine component is started, all rule files of the preset service can be acquired from a file system, a database, a remote data service and the like according to the selection of the storage medium, so that different rule files can be subsequently executed on different types of function classes in the preset service.
In this embodiment, when the rule engine is used, the rule file stored in the physical storage medium is collocated to implement the rule for updating the service without stopping the server, so as to facilitate dynamic management and update of the service.
On the basis of the service rule processing method provided in fig. 1, in step S110, acquiring a rule file of a preset service from a preset physical storage medium, further includes:
s310, if the rule reloading operation triggered by the preset rule reloading interface is detected, the first rule file reloaded by the rule reloading interface is obtained from the physical storage medium.
Firstly, for a rule engine, after the rule engine is started, acquiring a rule file of a preset service from a physical storage medium, and if the rule file needs to be operated, operating the rule file in a rule container; if the rule changes at this time, that is, if a rule reload operation occurs, the physical storage medium needs to be updated according to the contents of the new rule.
In this embodiment, a rule detection mechanism is further provided to prevent the problems of rule conflict and process deadlock during the rule execution process. And if the rule reloading operation triggered by the adopted preset rule reloading interface is detected, acquiring a first rule file reloaded by the rule reloading interface from the physical storage medium. Specifically, a rule reloading operation is performed on a rule reloading interface used in a rule service interface layer, such as zuul/admin/reload, to reload the changed first rule file, after the reloading, the rule becomes effective, and the first rule file reloaded by the rule reloading interface can be obtained from a physical storage medium corresponding to the rule.
In this embodiment, for the case that the business rule frequently changes, the whole server does not need to be restarted, and only the rule file after the heavy load change needs to be acquired from the physical storage medium after the rule is heavily loaded, so that the business personnel can adjust the rule file in time as required without the implementation of hard coding. Meanwhile, the rule file after the overloading can be immediately updated, so that the service can be conveniently and timely released, and the server can quickly respond to the requirement change.
On the basis of the service rule processing method provided in fig. 1, the present invention also provides a possible implementation manner of a rule writing method in the service rule processing method. Fig. 2 is a schematic flow chart of a rule writing method in a business rule processing method according to the present invention. As shown in fig. 2, in the step S110, acquiring the rule file of the preset service from the preset physical storage medium further includes:
and S410, acquiring rule data input by a user through a rule management interface.
In the development work, business personnel can hardly directly see the intention of the code, the rule engine can help the business personnel to organize the logic of the development requirement, when the business personnel obtains a new requirement and needs to change the business rule, the content of the rule file only needs to be modified, the rule file only needs to be stored after modification, a server does not need to be restarted, the project is deployed, and the maintainability is extremely high.
In order to implement a simple and operable rule editing process for business personnel, facilitate the business personnel to change rules in time, reduce the learning of rule logic and reduce the communication cost with technical personnel, a rule management interface is provided in the embodiment for a user to input and edit. Fig. 3 is a schematic diagram of a business rule management interface provided in the present invention. As shown in fig. 3, a user can input a rule name, a rule condition, and a rule result on the interface, select a rule attribute, and finally store the rule attribute, so that the visualized interactive interface enables the user to automatically convert data into a rule file that the Drools rule engine can understand and execute without understanding complex rule logic and only by inputting the rule according to requirements.
Therefore, after the user inputs the rule data, the business rule processing server can acquire the rule data input by the user through the rule management interface.
And S420, generating a rule file by adopting a preset conversion rule according to the rule data.
According to the rule data input by the user, the rule file can be generated by adopting a preset conversion rule. Fig. 4 is a schematic diagram of a service Rule generation flow in service Rule processing, as shown in fig. 4, after a user inputs Rule data on a Rule management interface, where Rule, When, Then, End are specific keywords of the Rule data, and the Rule keyword is followed by a Rule name; the Rule attribute of the Rule is between Rule and When, and indicates the Rule attribute that the Drools Rule engine can identify; among the conditions of the rule between When and Then, the rule condition indicates the condition required for the rule to be triggered, and When all the conditions are combined together to be True, the rule is triggered; between Then and End is the rule result of this rule, indicating the action that needs to be done after the rule is triggered.
Then, according to the above conversion rule, the rule data input by the user is generated into a rule file understandable by Drool.
And S430, calling a preset rule management interface, and writing the rule file into a physical storage medium.
In this embodiment, the rule file may be written by calling a rule service management interface of the rule service interface layer in advance, and then the rule file of the preset service may be acquired from the preset physical storage medium. Through the rule management interface, a user can write the rule directly by calling the interface. When a user inputs rule data through the rule management interface, the rule data generates a rule file through a conversion rule, the rule can be written through the preset rule management interface, and the rule file is written into the physical storage medium.
In the embodiment, a visual and editable rule management interface is provided for business personnel, the rule data can be generated into the rule file by directly acquiring the rule data from the rule management interface and utilizing the preset conversion rule, the business personnel do not need to learn and understand complex rule logic in advance, the development and maintenance workload is reduced, and the efficiency of business rule processing is improved.
On the basis of the rule writing method in the service rule processing method provided in fig. 2, in step S430, invoking a preset rule management interface, and writing the rule file into the physical storage medium includes:
and S510, calling a preset rule writing interface, and writing the rule file into the rule data and writing the rule data into the physical storage medium.
Specifically, in this embodiment, a rule writing interface in a preset rule management interface, such as a zuul/admin/save interface, may be invoked to write a rule file of a preset service into a preset physical storage medium. If the rule file corresponding to the preset service does not exist in the current preset physical storage medium, the service rule processing fails, and the required rule can be written.
In S510, the method further includes:
s610, calling a rule writing interface according to the at least one storage drive, and respectively writing the rule file into the physical storage medium corresponding to the at least one storage drive.
In this embodiment, the preset physical storage media include storage media such as a file system, a database, a remote data service, and the like, and correspondingly, the storage drives include storage drives such as a file system drive, a database drive, an internet storage drive, and the like, and when a rule is written, the rule writing interface is called according to at least one storage drive, and the rule file is written into the physical storage media corresponding to the at least one storage drive according to preset requirements. That is, if different requirements are required for storing the current rule file, the rule file may be stored in a required storage medium according to the selection.
In this embodiment, the rules are written into the physical storage media through the rule writing interface, and the rule files can be stored into different physical storage media through different storage drivers, so that the subsequent Drools rule engine does not need to perform halt and pause service when using the rule files, and only needs to directly obtain the rules from the corresponding physical storage media.
On the basis of any of the above embodiments, the present invention also provides a possible implementation manner of the rule triggering method in the business rule processing. Fig. 5 is a schematic flowchart of a rule triggering method in service rule processing provided by the present invention, as shown in fig. 5, the method further includes:
s710, if a rule trigger request triggered by a preset rule trigger interface is detected, querying a rule container associated with a second rule file triggered by the rule trigger interface from a preset memory.
After the rule engine is started, if a rule trigger request triggered by a preset rule trigger interface is detected, wherein the second rule file refers to a rule file which needs to be executed by the rule trigger request. Specifically, if a rule trigger interface preset by a rule service interface layer is detected, such as a rule trigger request triggered by zuul/rules/fire, since the interface is compatible with different services and scenes by means of uniform encapsulation of incoming references, if it is detected that service data is sent to fire rules through the zuul/rules/fire interface, a rule container associated with a second rule file triggered by the rule trigger interface is inquired from a preset memory, that is, whether a KieBase associated with the second rule file exists in the current kie connector is checked in a kiefile system, and if yes, S720 is executed; and if the KieBase associated with the second rule file does not exist in the current KieContainer, establishing the KieContainer according to the second rule, and referring to S110-S130. Optionally, the service data is transferred in an Object manner using Map < String, Object > type, and different types of objects may be supported, which is not limited in the present invention. Meanwhile, after the user uses the rule reloading interface, such as zuul/admin/reload, to perform rule reloading operation, the user can continue to use the rule triggering interface to trigger the rule triggering request.
S720, executing the rule data in the second rule file on the service data by adopting the rule container associated with the second rule file.
After the rule container associated with the second rule file triggered by the rule triggering interface is queried, the rule container associated with the second rule file can be adopted to execute the rule data in the second rule file on the service data. Specifically, a KieSession can be newly built according to the kiecondainer and the KieBase therein. KieSession represents the session of the Drools rules engine, including the rules in KieBase. After the rule container derives a session for processing a service request, service data can be inserted into the kiessesion to trigger a rule in the kiessesion, the rule in the kieesesion can be grouped, and the inserted service data can be judged in which group the service data needs to be executed by a grouping execution strategy, so that the rule in the group is triggered, that is, the rule data in the second rule file is executed on the service data to obtain a rule triggering result. In a possible implementation manner, after the rule execution rule logic is finished, the executed rule may be destroyed, and the resource is released.
In this embodiment, when a rule is triggered, as long as the rule to be executed is directly obtained from the preset memory, it is not necessary to perform the initialization of the rule engine again each time the rule is triggered and executed, which saves the flow; and the rule execution is carried out in the container, other threads are not influenced, and meanwhile, the user can freely trigger the rule according to the service data, so that the service maintenance is facilitated.
Fig. 6 is a schematic diagram of a business rule processing apparatus provided in the present invention, as shown in fig. 6, the business rule processing apparatus includes:
an obtaining module 1000, configured to obtain a rule file of a preset service from a preset physical storage medium;
the initialization module 2000 is configured to initialize the rule file into a rule management model of a preset rule engine;
the processing module 3000 is configured to write the rule management model including the rule file into a memory of the preset rule engine, to obtain a rule container of the preset service, where the rule container is configured to execute the rule data in the rule file on the service data of the preset service.
Optionally, the obtaining module 1000 is further configured to obtain all rule files of the preset service from the physical storage medium when the preset rule engine is started.
Optionally, the obtaining module 1000 is further specifically configured to obtain, if a rule reload operation triggered by a preset rule reload interface is detected, the first rule file reloaded by the rule reload interface from the physical storage medium.
Optionally, the service rule processing apparatus further includes a write-in module, where the write-in module is configured to obtain rule data input by a user through the rule management interface; generating a rule file by adopting a preset conversion rule according to the rule data; and calling a preset rule management interface, and writing the rule file into a physical storage medium.
Optionally, the writing module is specifically configured to call a preset rule writing interface, and write the rule file into the rule data and write the rule data into the physical storage medium.
Optionally, the writing module is further specifically configured to invoke a rule writing interface according to at least one storage drive, and respectively write the rule file into the physical storage medium corresponding to the at least one storage drive.
Optionally, the service rule processing apparatus further includes an execution module, where the execution module is configured to, if a rule trigger request triggered by a preset rule trigger interface is detected, query, from a preset memory, a rule container associated with a second rule file triggered by the rule trigger interface; and executing the rule data in the second rule file on the service data by adopting the rule container associated with the second rule file.
These above modules may be one or more integrated circuits configured to implement the above methods, such as: one or more Application Specific Integrated Circuits (ASICs), or one or more Digital Signal Processors (DSPs), or one or more Field Programmable Gate Arrays (FPGAs), etc. For another example, when one of the above modules is implemented in the form of a Processing element scheduler code, the Processing element may be a general-purpose processor, such as a Central Processing Unit (CPU) or other processor capable of calling program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
Fig. 7 is a schematic diagram of a business rule processing server according to the present invention. As shown in fig. 7, the business rule processing server 10 includes: a processor 11, a memory 12 and a bus 13, wherein the processor 11 and the memory 12 are connected via the bus 13, the memory 12 stores program instructions executable by the processor 11, and when the business rule processing server 10 runs, the processor 11 executes the program instructions to execute the above method embodiments. The specific implementation and technical effects are similar, and are not described herein again.
Optionally, the invention also provides a program product, for example a computer-readable storage medium, comprising a program which, when being executed by a processor, is adapted to carry out the above-mentioned method embodiments.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
The integrated unit implemented in the form of a software functional unit may be stored in a computer readable storage medium. The software functional unit is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to execute some steps of the methods according to the embodiments of the present invention. And the aforementioned storage medium includes: a U disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above description is only for the specific embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present invention are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.

Claims (10)

1. A method for processing business rules, the method comprising:
acquiring a rule file of a preset service from a preset physical storage medium;
initializing the rule file into a rule management model of a preset rule engine according to the rule file;
writing the rule management model containing the rule file into a memory of the preset rule engine to obtain a rule container of the preset service, wherein the rule container is used for executing the rule data in the rule file on the service data of the preset service.
2. The method according to claim 1, wherein the obtaining the rule file of the preset service from the preset physical storage medium comprises:
and when the preset rule engine is started, all rule files of the preset service are acquired from the physical storage medium.
3. The method according to claim 1, wherein the obtaining the rule file of the preset service from the preset physical storage medium further comprises:
and if the rule reloading operation triggered by the preset rule reloading interface is detected, acquiring a first rule file reloaded by the rule reloading interface from the physical storage medium.
4. The method according to claim 1, wherein the obtaining the rule file of the preset service from the preset physical storage medium further comprises:
acquiring the rule data input by a user through a rule management interface;
generating the rule file by adopting a preset conversion rule according to the rule data;
and calling a preset rule management interface, and writing the rule file into the physical storage medium.
5. The method of claim 4, wherein the invoking a preset rule management interface to write the rule data to the physical storage medium further comprises:
and calling a preset rule writing interface, and writing the rule file into the rule data and writing the rule data into the physical storage medium.
6. The method according to claim 5, wherein the calling a preset rule writing interface to write the rule file into the rule data to the physical storage medium comprises:
and calling the rule writing interface according to at least one storage drive, and respectively writing the rule file into the physical storage medium corresponding to the at least one storage drive.
7. The method according to any one of claims 1-6, further comprising:
if a rule triggering request triggered by a preset rule triggering interface is detected, inquiring a rule container associated with a second rule file triggered by the rule triggering interface from the preset memory;
and executing the rule data in the second rule file on the service data by adopting the rule container associated with the second rule file.
8. A business rule processing apparatus, the apparatus comprising:
the acquisition module is used for acquiring a rule file of a preset service from a preset physical storage medium;
the initialization module is used for initializing the rule file into a rule management model of a preset rule engine according to the rule file;
and the processing module is used for writing the rule management model containing the rule file into a memory of the preset rule engine to obtain a rule container of the preset service, and the rule container is used for executing the rule data in the rule file on the service data of the preset service.
9. A business rule processing server, comprising: a processor, a memory and a bus, the processor and the memory being connected by the bus, the memory storing program instructions executable by the processor, the processor executing the program instructions to perform the steps of the business rule processing method according to any one of claims 1 to 7 when the business rule processing server is running.
10. A computer-readable storage medium, characterized in that the storage medium has stored thereon a computer program which, when being executed by a processor, carries out the steps of the business rule processing method according to one of claims 1 to 7.
CN202210152223.4A 2022-02-18 2022-02-18 Business rule processing method and device, server and storage medium Pending CN114490694A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210152223.4A CN114490694A (en) 2022-02-18 2022-02-18 Business rule processing method and device, server and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210152223.4A CN114490694A (en) 2022-02-18 2022-02-18 Business rule processing method and device, server and storage medium

Publications (1)

Publication Number Publication Date
CN114490694A true CN114490694A (en) 2022-05-13

Family

ID=81482555

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210152223.4A Pending CN114490694A (en) 2022-02-18 2022-02-18 Business rule processing method and device, server and storage medium

Country Status (1)

Country Link
CN (1) CN114490694A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116662041A (en) * 2023-07-21 2023-08-29 太平金融科技服务(上海)有限公司 Service information processing method, device, computer equipment, medium and program product

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116662041A (en) * 2023-07-21 2023-08-29 太平金融科技服务(上海)有限公司 Service information processing method, device, computer equipment, medium and program product
CN116662041B (en) * 2023-07-21 2023-10-20 太平金融科技服务(上海)有限公司 Service information processing method, device, computer equipment, medium and program product

Similar Documents

Publication Publication Date Title
CN108762769B (en) Microservice application arranging and deploying method and device and computer terminal
CN108304201B (en) Object updating method, device and equipment
US5535389A (en) Business process objects with associated attributes such as version identifier
US7912826B2 (en) Apparatus, computer program product, and method for supporting construction of ontologies
CN105511873B (en) User interface control display method and device
US20080010082A1 (en) System and method for business process management
CN112363695B (en) PMML file and integration method of runtime environment and industrial software thereof
US20120102456A1 (en) System and Method of Annotating Class Models
CN111784108B (en) Modeling method and device of main data management platform
CN113094125B (en) Business process processing method, device, server and storage medium
CN116775183A (en) Task generation method, system, equipment and storage medium based on large language model
CN114064213A (en) Kubernets container environment-based rapid arranging service method and system
CN111695827A (en) Business process management method and device, electronic equipment and storage medium
CN117632372A (en) Helm-based continuous deployment management method
CN114490694A (en) Business rule processing method and device, server and storage medium
EP4163798A1 (en) Method and apparatus for managing model file in inference application
WO2024002302A1 (en) Application management method, application subscription method, and related device
CN116932147A (en) Streaming job processing method and device, electronic equipment and medium
CN102486731B (en) Strengthen the visualization method of the call stack of software of software, equipment and system
Shunkevich et al. Ontological approach to the development of a software model of a semantic computer based on the traditional computer architecture
US9059992B2 (en) Distributed mobile enterprise application platform
CN115981620A (en) Visual artificial intelligence algorithm arrangement method, device, equipment and medium
CN112486461B (en) Information processing system based on springboot framework
CN114547007A (en) Big data feature extraction method and device and computer-readable storage medium
CN113934748A (en) Mixed type SQL script file generation method, execution method and device

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