[go: up one dir, main page]

CN108920222B - Business processing method and device based on rule engine - Google Patents

Business processing method and device based on rule engine Download PDF

Info

Publication number
CN108920222B
CN108920222B CN201810763933.4A CN201810763933A CN108920222B CN 108920222 B CN108920222 B CN 108920222B CN 201810763933 A CN201810763933 A CN 201810763933A CN 108920222 B CN108920222 B CN 108920222B
Authority
CN
China
Prior art keywords
service
class
processing
service processing
rule
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
CN201810763933.4A
Other languages
Chinese (zh)
Other versions
CN108920222A (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.)
JD Digital Technology Holdings Co Ltd
Jingdong Technology Holding Co Ltd
Original Assignee
Beijing Jingdong Financial Technology Holding 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 Financial Technology Holding Co Ltd filed Critical Beijing Jingdong Financial Technology Holding Co Ltd
Priority to CN201810763933.4A priority Critical patent/CN108920222B/en
Publication of CN108920222A publication Critical patent/CN108920222A/en
Application granted granted Critical
Publication of CN108920222B publication Critical patent/CN108920222B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • G06F9/449Object-oriented method invocation or resolution

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a business processing method and device based on a rule engine, and relates to the technical field of computers. One embodiment of the method comprises: sending an object entity instance having a business input object, a business output object, and a business processing proxy object to a rules engine; matching corresponding rule files from the rule file set of the rule engine according to the object entity instance; wherein, the rule file comprises an execution function of the service processing agent class; and calling an execution function of the rule file to obtain a service processing object, performing corresponding service logic processing on the service input object through the service processing object, and packaging a service logic processing result into a service output object. The method declares the execution function of the business processing agent class in the rule file, transfers part of business processing logic from the rule file to the business processing object for execution, reduces the writing quantity of the rule file, and increases the readability and maintainability of the rule file.

Description

Business processing method and device based on rule engine
Technical Field
The invention relates to the field of computers, in particular to a business processing method and device based on a rule engine.
Background
In the software development process, business logic is constantly changed, and in order to adapt to the change of the business logic, a rule engine technology is introduced into business requirements. The realization principle of the rule engine technology is as follows: and abstracting the business logic into an object entity and a rule file, performing pattern matching by using a rule engine to screen out a proper rule file for the object entity, performing business logic processing on the object entity by using the screened rule file, and outputting a business logic processing result.
In the implementation process, the rule file needs to be written in a specific rule expression Language, for example, some rule engines are implemented using Extensible Markup Language (XML), some rule engines are implemented using Domain Specific Language (DSL), and developers need to learn a new set of rule expression Language. The object entity in the rule engine needs to be declared as an instance in advance, so that the object entity can be operated in the memory through the rule file. The rule file and the service logic are closely related, and a new rule file is required to be created every time a new service requirement exists.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art:
(1) the rule expression language of the rule engine is complicated, and developers are difficult to quickly get up; the rule expression language only abstracts the business logic to the rule file, and cannot reduce the complexity of the business logic, and in some cyclic business logics, the development of the rule file is even more difficult than the development of a native development language.
(2) In the face of relatively complex business logic, a large amount of writing and combining rules are needed to obtain rule files when a rule engine is used, so that the maintainability and usability of the whole project are low.
(3) Different business requirements are different and have universality, and as the rule files cannot be associated, developers need to repeatedly write the rule files for repeated business logic.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for service processing based on a rule engine, where an object entity instance is input to the rule engine to match a rule file including an execution function of a service processing proxy class, and the execution function of the rule file is called to obtain a service processing object, so as to perform service logic processing on the service input object. In the embodiment, only the execution function of the service processing agent class is reserved in the rule file, and part of service processing logic is decoupled from the rule file into the service processing object, so that the writing quantity of the rule file is reduced, and the readability and maintainability of the rule file are improved.
To achieve the above object, according to an aspect of the embodiments of the present invention, a method for processing a service based on a rule engine is provided.
The business processing method based on the rule engine comprises the following steps: sending an object entity instance having a business input object, a business output object, and a business processing proxy object to the rules engine; matching corresponding rule files from the rule file set of the rule engine according to the object entity instance; wherein, the rule file comprises an execution function of a service processing agent class; and calling an execution function of the rule file to obtain a service processing object, performing corresponding service logic processing on the service input object through the service processing object, and packaging a service logic processing result into the service output object.
Optionally, the method further comprises: defining the service processing proxy class, the service processing encapsulation class and the service processing class; the first parameter of the execution function of the service processing proxy class is the class name of the service processing class, and the rest parameters comprise the service input object and the service output object; the parameters of the executive function of the service processing encapsulation class are aligned with the second parameters of the service processing proxy class; the service processing class is an implementation subclass of the service processing encapsulation class.
Optionally, the invoking an execution function of the rule file to obtain a service processing object includes: calling an execution function of the service processing proxy class of the rule file to obtain parameters of the execution function, wherein the first parameter is a class name of the service processing class; and acquiring the service processing object of the service processing class through a reflection mechanism according to the class name of the service processing class.
Optionally, the performing, by the service processing object, corresponding service logic processing on the service input object includes: and inputting the service input object into an execution function of the service processing object so as to perform corresponding service logic processing on the service input object.
Optionally, the method further comprises: and monitoring the update of the rule file in the rule file set through a polling mechanism so as to manage the rule file in the cache.
To achieve the above object, according to another aspect of the embodiments of the present invention, a business processing apparatus based on a rule engine is provided.
The business processing device based on the rule engine of the embodiment of the invention comprises: a sending module, configured to send an object entity instance having a service input object, a service output object, and a service processing proxy object to the rule engine; the matching module is used for matching a corresponding rule file from the rule file set of the rule engine according to the object entity instance; wherein, the rule file comprises an execution function of a service processing agent class; and the processing module is used for calling the execution function of the rule file to obtain a service processing object, performing corresponding service logic processing on the service input object through the service processing object, and packaging a service logic processing result into the service output object.
Optionally, the apparatus further comprises: the defining module is used for defining the service processing proxy class, the service processing encapsulation class and the service processing class; the first parameter of the execution function of the service processing proxy class is the class name of the service processing class, and the rest parameters comprise the service input object and the service output object; the parameters of the executive function of the service processing encapsulation class are aligned with the second parameters of the service processing proxy class; the service processing class is an implementation subclass of the service processing encapsulation class.
Optionally, the processing module is further configured to: calling an execution function of the service processing proxy class of the rule file to obtain parameters of the execution function, wherein the first parameter is a class name of the service processing class; and acquiring the service processing object of the service processing class through a reflection mechanism according to the class name of the service processing class.
Optionally, the processing module is further configured to: and inputting the service input object into an execution function of the service processing object so as to perform corresponding service logic processing on the service input object.
Optionally, the apparatus further comprises: and the monitoring module is used for monitoring the update of the rule file in the rule file set through a polling mechanism so as to manage the rule file in the cache.
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; the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors realize the business processing method based on the rule engine.
To achieve the above object, according to still another aspect of embodiments of the present invention, there is provided a computer-readable medium.
A computer-readable medium of an embodiment of the present invention stores thereon a computer program, which, when executed by a processor, implements a rule engine-based business processing method of an embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: by declaring an execution function of a business processing agent class in the rule file, part of business processing logic is transferred from the rule file to a business processing object for execution, the rule file is light and simple, the writing quantity of the rule file is reduced, and the readability and maintainability of the rule file are improved; the definition of classes and the service execution logic of the execution function are realized through a native development language (namely a programming language used when the whole system is developed), so that a developer can quickly start; the service logic is executed through the execution function of the service processing object, so that the universality can be extracted, and the repeated work can be reduced; and the updating of the rule file is monitored, so that the rule file is conveniently managed.
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 the main steps of a rules engine based business processing method according to an embodiment of the present invention;
FIG. 2 is a schematic main flow chart of a business processing method based on a rule engine according to an embodiment of the invention;
FIG. 3 is a diagram illustrating the relationship between a business process proxy class, a business process encapsulation class, and a business process class according to an embodiment of the present invention;
FIG. 4 is a schematic diagram illustrating an implementation principle of a business processing method based on a rule engine according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of the main modules of a rules engine based business processing apparatus according to an embodiment of the present invention;
FIG. 6 is a schematic structural diagram of a business processing apparatus based on a rule engine 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 diagram of a computer apparatus suitable for use in an electronic device to implement an embodiment of the 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.
Fig. 1 is a schematic diagram of main steps of a business processing method based on a rule engine according to an embodiment of the present invention. As shown in fig. 1, the method for processing a service based on a rule engine according to the embodiment of the present invention mainly includes the following steps:
step S101: and sending the object entity instance with the business input object, the business output object and the business processing proxy object to the rule engine. Different service types, such as data cleaning, data screening, etc., have different data structures of service input objects, and in order to achieve a certain commonality, the service input object and the service output object may be stored in the form of a Map Key-Value pair (Key-Value). In this step, the service input object is original service data, the service output object is a null object, and the service processing proxy object needs to be predefined according to the service type. And taking the business input object, the business output object and the business processing proxy object as object entity instances and sending the object entity instances to the rule engine.
Step S102: and matching a corresponding rule file from the rule file set of the rule engine according to the object entity instance, wherein the rule file comprises an execution function of a service processing agent class. The writing principle of the rule file in the rule file set is as follows: and filling an execution function of the service processing agent class in the rule file, and writing parameters needing to be transmitted into the rule file through the execution function without managing other service logics. The executive function of the service processing proxy class comprises a service input object and a service output object, the executive function of the service processing proxy class is called by using a rule file subsequently, parameters with variable quantity and variable data structure are transmitted, and specific service logic is defined in the service processing class due to the fact that the transmitted first parameter is the class name of the service processing class, and further specific service logic processing can be achieved through the service processing object of the service processing class. When matching the object entity instance with the rule file is realized, any one of the following modes can be adopted: and (3) directly accessing rule engines such as Drools, Easy-rules and the like by using a matching algorithm such as Rete, Tread and the like and a rule matching method written by the user.
Step S103: and calling an execution function of the rule file to obtain a service processing object, performing corresponding service logic processing on the service input object through the service processing object, and packaging a service logic processing result into the service output object. The step is that the class name of the service processing class is obtained according to the service processing proxy class in the rule file; then, according to the class name of the service processing class, acquiring a service processing object of the service processing class through a reflection mechanism; inputting the service input object into an execution function of the service processing object so as to perform corresponding service logic processing on the service input object; and packaging the obtained service logic processing result into a service output object for output.
Fig. 2 is a schematic main flow diagram of a business processing method based on a rule engine according to an embodiment of the present invention. As shown in fig. 2, the method for processing a service based on a rule engine according to an embodiment of the present invention mainly includes the following steps:
step S201: defining a service processing proxy class, a service processing encapsulation class and a service processing class, wherein the service processing class is an implementation subclass of the service processing encapsulation class. The definition of the three classes in the step is written by using a native language, such as Java language, and the method has no hand difficulty. The parameters of the execution function of the service processing proxy class comprise an input object instance and an output object instance, and are used for performing declaration filling in a rule file. The business processing encapsulation class defines an execution function comprising an input object instance and an output object instance, and the parameters of the execution function of the business processing encapsulation class are aligned with the second parameters of the business processing proxy class to transparently transmit all business parameters. And the service processing class is used for processing the service access parameter and the access parameter in the rule file to complete a specific service processing logic.
The execution function of the service processing proxy class is as follows: execute (Object … objects). The execution function is a parameter variable length function, and parameters with variable quantity and variable data structure can be transmitted through the calling of the execution function of the service processing proxy class in the rule file. The first bit of the parameter list of the execution function is a reserved bit of the class name of the service handling class.
The execution function of the service processing encapsulation class is as follows: execute (Object … objects). The parameters of the execution function are aligned with the second parameters of the service processing proxy class, i.e. if there are n parameters in the service processing proxy class, the parameters transmitted into the service processing encapsulation class are the last n-1, and the first parameter is not transmitted.
The service processing class is a subclass of the service processing encapsulation class, and according to different service logics, the implementation logics are different, the number of the service processing classes is not fixed, the cutting granularity (namely, one service logic is completed in several steps) is not fixed, but both the input parameter and the output parameter of an execution function (execute) are specified, and developers can complete the development of the service processing class according to specific service types.
In a preferred embodiment, better generality can be achieved among the service processing proxy class, the service processing encapsulation class and the service processing class through a universal cache design, a tool function and the like. Wherein the universal cache design is a singleton schema in the design module.
Fig. 3 is a schematic diagram of a relationship between a service processing proxy class, a service processing encapsulation class, and a service processing class according to an embodiment of the present invention. As shown in fig. 3, a service processing proxy class is called by using a class name of a service processing class indicated in a rule file, and a service processing object of the service processing class is obtained through a Java reflection mechanism; parameters in the business processing proxy class except the first parameter are then transmitted into an execution function of the business processing object.
In data mining, it is usually necessary to perform data preprocessing on original service data to obtain information more effectively, and the data preprocessing includes multiple services. Taking data cleaning service as an example, the service includes service types such as OneHot expansion, data standardization and the like, wherein OneHot is a coding mode. Taking data standardization as an example, the implementation code of the execution function (execute) of the service processing object may be:
Figure BDA0001728562970000081
Figure BDA0001728562970000091
step S202: and constructing a rule file set with the execution function of the business processing proxy class. The writing principle of the rule file in the rule file set is as follows: and filling an execution function of the service processing agent class in the rule file, and writing parameters needing to be transmitted into the rule file through the execution function without managing other service logics. The file format of the rule file may be a DSL file, an XML file, a YML file, or the like. Where the YML file is in a file format written in YAML (YAML Ain't Markup Language) which is a foreign Language abbreviation for "YAML is not a Markup Language".
Still taking the data cleansing service as an example, the rule file may be written in the following code:
Figure BDA0001728562970000092
in the above example, the file format of the rule file is a YML file, and the first 5 rows thereof are respectively a rule name, a rule description, priority information, condition information, and rule execution information. The priority information defines the priority level of the rule file, and when a plurality of rule files are matched for the target entity instance in the step, the rule files can be executed in sequence according to the priority level. The condition information defines a namespace of rnn for the input data. The class of service handling agent in the rule file is rulesExecutorUser. The execution function of the service processing proxy class includes 5 parameters, which are in turn: "com.jd.find.vector.astroboy.rule.executive.matrix.inloop.executive.normallizeexecutive \", \\ tempCurrentHostCount \ 10, 50 and "normalzecurrenthostcount \ the first parameter is the class name of the service handling class. Starting from actions to the end of the execution part of the rule file, the meaning is: and performing data standardization processing with the upper limit and the lower limit of [10, 50] on the field "tempCurrentHostCount" by using an execution function of a service processing object (namely, an object corresponding to a first parameter of the rule file). Wherein the data normalization is to scale the data to fall within a small specified interval. In an embodiment, the data normalization may be implemented by min-max normalization, and the specific formula is as follows:
y=((x-MinValue)/(MaxValue-MinValue))(new_MaxValue-new_MinValue)+new_minValue
equation 1
In the formula, y is a result after data cleaning, x is original service data, MinValue is a minimum value of the original service data, MaxValue is a maximum value of the original service data, new _ MaxValue is an upper limit of the data cleaning, and new _ MinValue is a lower limit of the data cleaning.
Step S203: and sending an object entity instance to a rule engine, wherein the object entity instance comprises a business input object, a business output object and a business processing proxy object. The rules engine in an embodiment is an Easy-rules engine. In order to achieve a certain generality, in the embodiment, the service input Object is stored in a Key-Value form, where Key is a parameter name (corresponding to \ tempCurrentHostCount \ in a rule file code), a data type of the Key is, for example, a String and a Json (JavaScript Object notification, which is a lightweight data exchange format) String, Value is a parameter Value, and a data type of the Value is a common parent Object class of Java objects. Also in consideration of generality, the service output object is also stored in a form of Key-Value, the Key (corresponding to \ normalized currenthostcount \ in the rule file code) of the service output object is derived from the parameter definition in the rule file, and the Value is derived from the subsequent service logic processing result. And the empty object of the business output object, namely the business output object sent to the rule engine, is empty.
Still taking the data cleansing service as an example, the service input object is original service data, such as original service data in Json format or String format. And finally outputting the service output object which is the field after data cleaning.
Step S204: and matching a corresponding rule file from the rule file set of the rule engine according to the object entity instance. In the embodiment, the matching of the object entity instance and the rule file is realized by directly accessing an Easy-rules rule engine. Of course, matching between the object entity instance and the rule file can be realized by using a matching algorithm and a self-written rule matching method.
The following is an implementation code of the rule matching method:
Figure BDA0001728562970000111
step S205: and calling an execution function of the rule file to obtain a service processing object, performing corresponding service logic processing on the service input object through the service processing object, and packaging a service logic processing result into the service output object. Calling an execution function of the service processing proxy class by using a rule file to obtain a parameter of the execution function; and acquiring the first parameter to obtain the class name of the service processing class, and then acquiring the service processing object through a reflection mechanism. Still taking the data cleaning service as an example, the implementation code for obtaining the service processing object according to the class name to perform corresponding service logic processing on the service input object through the service processing object may be:
Figure BDA0001728562970000112
Figure BDA0001728562970000121
in the above code, through a first parameter of an execution function (execute) of a service processing proxy class (ruleexecuuter user corresponding to a rule file code) in a rule file, that is, a class name of a service processing class, a service processing object (ruleexecuuter corresponding to the code in this step) of the service processing class is acquired by using a Java reflection mechanism, and the execution function (execute) of the service processing object is called to implement service logic. The specific service logic needs to be implemented by an execution function (execute) of the service processing object, that is, the data cleansing service of this embodiment needs to be implemented by the execution function (execute).
In a preferred embodiment, the rule files in the rule file set are stored in a rule cache, and the update of the rule files in the rule cache is monitored through a long connection, so that the rule files are managed conveniently. Storing the rule file in the rule cache can better receive data with larger data size or streaming data. In another preferred embodiment, the business processing object is stored, and the update of the business processing object is monitored, so as to facilitate dynamic loading.
Fig. 4 is a schematic diagram illustrating an implementation principle of a business processing method based on a rule engine according to an embodiment of the present invention. As shown in fig. 4, the implementation principle of the rule engine-based service processing method according to the embodiment of the present invention is as follows: abstracting the service logic to obtain an object entity instance and at least one rule file; inputting the object entity instance and at least one rule file into a rule engine for pattern matching; and calling the execution function of the service processing proxy class by using the matched rule file to obtain a service processing object, performing corresponding service logic processing by using the execution function of the service processing object, and packaging a service logic processing result into the service output object for output. Wherein the object entity instance, the rule file, the business process proxy class, the execution function, and the business process object are defined as described above.
According to the business processing method based on the rule engine, disclosed by the embodiment of the invention, the execution function of the business processing agent class is declared in the rule file, and part of business processing logic is transferred from the rule file to the business processing object for execution, so that the rule file is light and simple, the compiling quantity of the rule file is reduced, and the readability and maintainability of the rule file are improved; the definition of classes and the service execution logic of the execution function are realized through the native development language, so that developers can quickly get the right; the service logic is executed through the execution function of the service processing object, so that the universality can be extracted, and the repeated work can be reduced; and the updating of the rule file is monitored, so that the rule file is conveniently managed.
Fig. 5 is a schematic diagram of main modules of a business processing apparatus based on a rule engine according to an embodiment of the present invention. As shown in fig. 5, a business processing apparatus 400 based on a rule engine according to an embodiment of the present invention mainly includes:
a sending module 501, configured to send an object entity instance having a service input object, a service output object, and a service processing proxy object to the rule engine. Different service types, such as data cleaning, data screening, and the like, and different data structures of service input objects, in order to achieve a certain commonality, a Map Key Value pair (Key-Value) form may be used to store the service input object and the service output object. In the module, the service input object is original service data, the service output object is a null object, and the service processing proxy object needs to be abstracted according to a service type. And taking the business input object, the business output object and the business processing proxy object as object entity instances and sending the object entity instances to the rule engine.
A matching module 502, configured to match a corresponding rule file from a rule file set of the rule engine according to the object entity instance; wherein, the rule file comprises an execution function of the service processing agent class. The writing principle of the rule file in the rule file set is as follows: and filling an execution function of the service processing agent class in the rule file, and writing parameters needing to be transmitted into the rule file through the execution function without managing other service logics. The executive function of the service processing proxy class comprises a service input object and a service output object, the executive function of the service processing proxy class is called by using a rule file subsequently, parameters with variable quantity and variable data structure are transmitted, and specific service logic is defined in the service processing class due to the fact that the transmitted first parameter is the class name of the service processing class, and further specific service logic processing can be achieved through the service processing object of the service processing class. When matching the object entity instance with the rule file is realized, any one of the following modes can be adopted: and (3) directly accessing rule engines such as Drools, Easy-rules and the like by using a matching algorithm such as Rete, Tread and the like and a rule matching method written by the user.
The processing module 503 is configured to call an execution function of the rule file to obtain a service processing object, perform corresponding service logic processing on the service input object through the service processing object, and package a service logic processing result into the service output object. The module obtains the class name of the service processing class according to the service processing proxy class in the rule file; then, according to the class name of the service processing class, acquiring a service processing object of the service processing class through a reflection mechanism; inputting the service input object into an execution function of the service processing object so as to perform corresponding service logic processing on the service input object; and packaging the obtained service logic processing result into a service output object for output.
In addition, the rule engine-based service processing apparatus 500 according to the embodiment of the present invention may further include: a definition module and a monitoring module (not shown in fig. 5), wherein the definition module is configured to define the service processing proxy class, the service processing encapsulation class, and the service processing class according to a service type; the first parameter of the execution function of the service processing proxy class is the class name of the service processing class; the parameters of the executive function of the service processing encapsulation class are aligned with the second parameters of the service processing proxy class; the service processing class is an implementation subclass of the service processing encapsulation class. And the monitoring module is used for monitoring the update of the rule file in the rule file set through a polling mechanism so as to manage the rule file in the cache.
Fig. 6 is a schematic structural diagram of a business processing apparatus based on a rule engine according to an embodiment of the present invention. As shown in fig. 6, in the service processing apparatus based on the rule engine according to the embodiment of the present invention, the service processing module includes a service processing proxy class, a service processing encapsulation class, and a service processing class. The definition of the service processing agent class, the service processing encapsulation class and the service processing class is as described above, the module is a service logic decoupled from the engine rules, and the universality of the service processing module can be extracted along with the accumulation of development projects, so that the repeated work is reduced.
The object entity instance comprises a business processing proxy object of a business input object, a business output object and a business processing proxy class. The service input object and the service output object are jointly used as parameters of the service processing module to be transmitted, but are not generated in the service processing module, so that the service processing modules of different services can process the same data instance, and the operation of putting in/taking out the data instance for multiple times is avoided.
The rule engine comprises a rule engine instance and a rule engine agent; the rule engine instance realizes the matching of the rule instance and the object entity instance; the rule engine agent directly interacts with a data user and needs two memory examples, namely a rule example and an object entity example, on one hand, the rule engine agent encapsulates different changes caused by using the rule engine example at the bottom layer, and provides a unified calling interface for the outside at the layer; and on the other hand, the life cycle of the rule engine instance is managed, and the rule engine instance is prevented from being repeatedly established for many times. The rule engine can realize the business logic only by processing three objects in the object entity instance, and does not need to carry out additional rule definition, thereby reducing the complexity of the rule file, and increasing the readability and the maintainability of the rule file.
The rule examples comprise rule files and rule caches; the rule file can be put into storage media such as a database and the like, so that the management of the business processing device is facilitated; the rule cache is used for storing rule files so as to better receive data with larger data size or streaming data.
The cache management module comprises rule cache monitoring, rule cache management and service processing module cache; the rule cache monitoring realizes a long connection, and when a rule file in a database is updated, the rule cache monitoring informs rule cache management to carry out corresponding operation; the service processing module caches data used for storing the service processing module, and monitors updating of the module to support the requirement of dynamic loading of the data.
As can be seen from the above description, by declaring the execution function of the service processing proxy class in the rule file, part of the service processing logic is transferred from the rule file to the service processing object for execution, the rule file is light and simple, the writing quantity of the rule file is reduced, and the readability and maintainability of the rule file are increased; the definition of classes and the service execution logic of the execution function are realized through the native development language, so that developers can quickly get the right; the service logic is executed through the execution function of the service processing object, so that the universality can be extracted, and the repeated work can be reduced; and the updating of the rule file is monitored, so that the rule file is conveniently managed.
Fig. 7 illustrates an exemplary system architecture 700 of a rules engine based business process method or a rules engine based business process apparatus to which embodiments of the 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. Various communication client applications, such as shopping applications, web browser applications, search applications, instant messaging tools, mailbox clients, social platform software, and the like, may be installed on the terminal devices 701, 702, and 703.
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 that provides various services, such as a background management server that processes raw service data obtained by an administrator using the terminal devices 701, 702, and 703. The background management server may perform data cleaning and other processing on the received original service data, and feed back a processing result (e.g., a data cleaning result) to the terminal device.
It should be noted that the rule engine based service processing method provided in the embodiment of the present application is generally executed by the server 705, and accordingly, the rule engine based service processing apparatus is generally disposed 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.
The invention also provides an electronic device and a computer readable medium according to the embodiment of the invention.
The electronic device of the present invention includes: one or more processors; the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors realize the business processing method based on the rule engine.
The computer readable medium of the present invention stores thereon a computer program, which when executed by a processor implements a rules engine based business processing method of an embodiment of the present invention.
Referring now to FIG. 8, shown is a block diagram of a computer system 800 suitable for use in implementing an electronic device of an embodiment of the present invention. The electronic 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 computer 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 portion 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, the processes described above with respect to the main step diagrams may be implemented as computer software programs, according to embodiments of the present disclosure. 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 containing program code for performing the method illustrated in the main step diagram. 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 sending module, a matching module, and a processing module. Where the names of these modules do not in some cases constitute a limitation on the modules themselves, for example, a sending module may also be described as a module that sends an object entity instance having a business input object, a business output object, and a business process proxy object to the rules engine.
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: sending an object entity instance having a business input object, a business output object, and a business processing proxy object to the rules engine; matching corresponding rule files from the rule file set of the rule engine according to the object entity instance; wherein, the rule file comprises an execution function of a service processing agent class; and calling an execution function of the rule file to obtain a service processing object, performing corresponding service logic processing on the service input object through the service processing object, and packaging a service logic processing result into the service output object.
As can be seen from the above description, by declaring the execution function of the service processing proxy class in the rule file, part of the service processing logic is transferred from the rule file to the service processing object for execution, the rule file is light and simple, the writing quantity of the rule file is reduced, and the readability and maintainability of the rule file are increased; the definition of classes and the service execution logic of the execution function are realized through the native development language, so that developers can quickly get the right; the service logic is executed through the execution function of the service processing object, so that the universality can be extracted, and the repeated work can be reduced; and the updating of the rule file is monitored, so that the rule file is conveniently managed.
The product can execute the method provided by the embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method. For technical details that are not described in detail in this embodiment, reference may be made to the method provided by the embodiment of the present invention.
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 (12)

1. A business processing method based on a rule engine is characterized by comprising the following steps:
sending an object entity instance having a business input object, a business output object, and a business processing proxy object to the rules engine;
matching corresponding rule files from the rule file set of the rule engine according to the object entity instance; wherein, the rule file comprises an execution function of a service processing agent class;
and calling an execution function of the rule file to obtain a service processing object, performing corresponding service logic processing on the service input object through the service processing object, and packaging a service logic processing result into the service output object.
2. The method of claim 1, further comprising:
defining the service processing proxy class, the service processing encapsulation class and the service processing class; the first parameter of the execution function of the service processing proxy class is the class name of the service processing class, and the rest parameters comprise the service input object and the service output object; the parameters of the executive function of the service processing encapsulation class are aligned with the second parameters of the service processing proxy class; the service processing class is an implementation subclass of the service processing encapsulation class.
3. The method of claim 1, wherein invoking the execution function of the rule file to obtain a business process object comprises:
calling an execution function of the service processing proxy class of the rule file to obtain parameters of the execution function, wherein the first parameter is a class name of the service processing class;
and acquiring the service processing object of the service processing class through a reflection mechanism according to the class name of the service processing class.
4. The method of claim 1, wherein performing corresponding business logic processing on the business input object through the business processing object comprises: and inputting the service input object into an execution function of the service processing object so as to perform corresponding service logic processing on the service input object.
5. The method according to any one of claims 1 to 4, further comprising: and monitoring the update of the rule file in the rule file set through a polling mechanism so as to manage the rule file in the cache.
6. A rules engine based business processing apparatus, comprising:
a sending module, configured to send an object entity instance having a service input object, a service output object, and a service processing proxy object to the rule engine;
the matching module is used for matching a corresponding rule file from the rule file set of the rule engine according to the object entity instance; wherein, the rule file comprises an execution function of a service processing agent class;
and the processing module is used for calling the execution function of the rule file to obtain a service processing object, performing corresponding service logic processing on the service input object through the service processing object, and packaging a service logic processing result into the service output object.
7. The apparatus of claim 6, further comprising: the definition module is used for defining the service processing proxy class, the service processing encapsulation class and the service processing class according to the service type; the first parameter of the execution function of the service processing proxy class is the class name of the service processing class, and the rest parameters comprise the service input object and the service output object; the parameters of the executive function of the service processing encapsulation class are aligned with the second parameters of the service processing proxy class; the service processing class is an implementation subclass of the service processing encapsulation class.
8. The apparatus of claim 6, wherein the processing module is further configured to:
calling an execution function of the service processing proxy class of the rule file to obtain a parameter of the execution function; and
and acquiring the service processing object of the service processing class through a reflection mechanism according to the class name of the service processing class.
9. The apparatus of claim 6, wherein the processing module is further configured to: and inputting the service input object into an execution function of the service processing object so as to perform corresponding service logic processing on the service input object.
10. The apparatus of any of claims 6 to 9, further comprising: and the monitoring module is used for monitoring the update of the rule file in the rule file set through a polling mechanism so as to manage the rule file in the cache.
11. An electronic device, comprising:
one or more processors;
a storage device for storing 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-5.
12. 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-5.
CN201810763933.4A 2018-07-12 2018-07-12 Business processing method and device based on rule engine Active CN108920222B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810763933.4A CN108920222B (en) 2018-07-12 2018-07-12 Business processing method and device based on rule engine

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810763933.4A CN108920222B (en) 2018-07-12 2018-07-12 Business processing method and device based on rule engine

Publications (2)

Publication Number Publication Date
CN108920222A CN108920222A (en) 2018-11-30
CN108920222B true CN108920222B (en) 2021-12-03

Family

ID=64411166

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810763933.4A Active CN108920222B (en) 2018-07-12 2018-07-12 Business processing method and device based on rule engine

Country Status (1)

Country Link
CN (1) CN108920222B (en)

Families Citing this family (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110351359A (en) * 2019-07-09 2019-10-18 泰康保险集团股份有限公司 Message data processing method, device, electronic equipment and computer-readable medium
CN110532041A (en) * 2019-08-29 2019-12-03 深圳前海环融联易信息科技服务有限公司 Regulation engine method for parameter configuration, device, computer equipment and storage medium
CN112491940B (en) * 2019-09-12 2024-05-24 北京京东振世信息技术有限公司 Request forwarding method and device of proxy server, storage medium and electronic equipment
CN110647546A (en) * 2019-09-18 2020-01-03 北京明略软件系统有限公司 Third-party rule engine generation method and device
CN110865804A (en) * 2019-09-30 2020-03-06 天阳宏业科技股份有限公司 Rule engine optimization method, device, system and storage medium
CN110737439B (en) * 2019-10-18 2022-07-22 四川长虹电器股份有限公司 Equipment control system and method based on rule file
CN112788075B (en) * 2019-11-07 2024-04-09 北京京东尚科信息技术有限公司 Business service monitoring method and device
CN111143408B (en) * 2019-11-25 2023-08-22 泰康保险集团股份有限公司 Event processing method and device based on business rule
CN113282274B (en) * 2020-02-20 2023-09-22 北京京东振世信息技术有限公司 Data processing method and device
CN111427701A (en) * 2020-03-09 2020-07-17 中国建设银行股份有限公司 Workflow engine system and business processing method
CN111368206A (en) * 2020-03-17 2020-07-03 深圳市前海随手数据服务有限公司 Service recommendation method, device, server and storage medium
CN111399818B (en) * 2020-03-17 2023-10-20 深圳市卡牛科技有限公司 Recommendation engine design method, recommendation engine design device, server and storage medium
CN111562964A (en) * 2020-04-23 2020-08-21 深圳证券通信有限公司 Settlement service system simulator implementation method based on rule engine
CN112882800A (en) * 2021-03-15 2021-06-01 政采云有限公司 Method, device, system, equipment and medium for acquiring service execution result
CN114020372B (en) * 2021-11-22 2025-05-13 猪八戒股份有限公司 Data processing method, device and storage medium based on rule engine
CN114168581A (en) * 2021-12-13 2022-03-11 平安养老保险股份有限公司 Data cleaning method, device, computer equipment and storage medium
CN114422586B (en) * 2022-01-19 2023-10-27 平安付科技服务有限公司 Event notification method, device, computer equipment and storage medium
CN114841797A (en) * 2022-05-16 2022-08-02 中国邮政储蓄银行股份有限公司 Method and device for determining business processing rule based on Drools rule engine
CN115599355B (en) * 2022-12-12 2023-03-14 卓望数码技术(深圳)有限公司 Object-oriented big data processing method
CN119494713A (en) * 2024-10-14 2025-02-21 深圳市雁联计算系统有限公司 A method and system for dynamically maintaining access to digital RMB operating institutions

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102231162A (en) * 2011-07-01 2011-11-02 福建富士通信息软件有限公司 Dynamic rule engine configuration method based on service processing
CN103927174A (en) * 2014-04-17 2014-07-16 北京视博数字电视科技有限公司 Service processing method and device
CN103942228A (en) * 2013-01-23 2014-07-23 纽海信息技术(上海)有限公司 Rule engine, calculating method, service system and calling method
CN105653268A (en) * 2015-12-28 2016-06-08 中国民航信息网络股份有限公司 Rule engine debugging method and rule engine debugging system
CN107220098A (en) * 2017-06-14 2017-09-29 北京奇艺世纪科技有限公司 The implementation method and device of regulation engine

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7937669B2 (en) * 2007-06-12 2011-05-03 Honeywell International Inc. Access control system with rules engine architecture
CN101101651A (en) * 2007-08-01 2008-01-09 中兴通讯股份有限公司 Conversion processing method, system and conversion rule engine for electronic worksheet data
US9171252B2 (en) * 2012-10-11 2015-10-27 Sap Se Synchronization for context-aware complex event processing
CN107704265B (en) * 2017-09-30 2020-08-18 电子科技大学 A configurable rule generation method for business flow

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102231162A (en) * 2011-07-01 2011-11-02 福建富士通信息软件有限公司 Dynamic rule engine configuration method based on service processing
CN103942228A (en) * 2013-01-23 2014-07-23 纽海信息技术(上海)有限公司 Rule engine, calculating method, service system and calling method
CN103927174A (en) * 2014-04-17 2014-07-16 北京视博数字电视科技有限公司 Service processing method and device
CN105653268A (en) * 2015-12-28 2016-06-08 中国民航信息网络股份有限公司 Rule engine debugging method and rule engine debugging system
CN107220098A (en) * 2017-06-14 2017-09-29 北京奇艺世纪科技有限公司 The implementation method and device of regulation engine

Also Published As

Publication number Publication date
CN108920222A (en) 2018-11-30

Similar Documents

Publication Publication Date Title
CN108920222B (en) Business processing method and device based on rule engine
CN111400061A (en) A data processing method and system
CN110109983B (en) Method and device for operating Redis database
US9218100B2 (en) Method and system for partitioning asset management plugins
US11385945B2 (en) Method and system for event consumer management in an aggregated event platform
CN113760638B (en) A log service method and device based on kubernetes cluster
CN111427701A (en) Workflow engine system and business processing method
CN110795315A (en) Method and apparatus for monitoring services
CN114816393A (en) Information generation method, apparatus, device, and storage medium
CN114490136A (en) Service invocation and provisioning methods, apparatus, electronic equipment, media and program products
CN113448570A (en) Data processing method and device, electronic equipment and storage medium
CN110795135A (en) A method and apparatus for realizing annotated configuration
CN112650804A (en) Big data access method, device, system and storage medium
CN109947861B (en) Method, apparatus and computer readable medium for data warehouse to generate target table
CN113821519B (en) Data processing method and domain drive design architecture
CN114816483A (en) A development method and device for a business system
CN113934761B (en) A method and device for data processing
CN114268558B (en) Method, device, equipment and medium for generating monitoring graph
CN113495747A (en) Gray scale publishing method and device
US12026558B2 (en) Integration extensions
CN111736824A (en) Application data processing method and device, electronic device, storage medium
CN112925795A (en) Order data processing method and device
CN115658424B (en) Monitoring methods, devices, equipment, media and program products based on knowledge graphs
CN113760720B (en) Method and device for displaying abnormal information of codes
CN118093072A (en) Method, device, electronic equipment and storage medium for processing component

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
CP01 Change in the name or title of a patent holder

Address after: 101111 Room 221, 2nd Floor, Block C, 18 Kechuang 11th Street, Beijing Economic and Technological Development Zone

Patentee after: Jingdong Technology Holding Co.,Ltd.

Address before: 101111 Room 221, 2nd Floor, Block C, 18 Kechuang 11th Street, Beijing Economic and Technological Development Zone

Patentee before: Jingdong Digital Technology Holding Co.,Ltd.

Address after: 101111 Room 221, 2nd Floor, Block C, 18 Kechuang 11th Street, Beijing Economic and Technological Development Zone

Patentee after: Jingdong Digital Technology Holding Co.,Ltd.

Address before: 101111 Room 221, 2nd Floor, Block C, 18 Kechuang 11th Street, Beijing Economic and Technological Development Zone

Patentee before: JINGDONG DIGITAL TECHNOLOGY HOLDINGS Co.,Ltd.

Address after: 101111 Room 221, 2nd Floor, Block C, 18 Kechuang 11th Street, Beijing Economic and Technological Development Zone

Patentee after: JINGDONG DIGITAL TECHNOLOGY HOLDINGS Co.,Ltd.

Address before: 101111 Room 221, 2nd Floor, Block C, 18 Kechuang 11th Street, Beijing Economic and Technological Development Zone

Patentee before: BEIJING JINGDONG FINANCIAL TECHNOLOGY HOLDING Co.,Ltd.

CP01 Change in the name or title of a patent holder