Background technology
Regulation engine (regular rule) refers to the rule in one section understandable script represenation business procedure, script does not need through compiling, read and explain by the regulation engine framework in the program runtime, application call regulation engine interface triggers carries out corresponding rule, thereby reaches service logic and separating that business programming is realized.
Regulation engine is different from the rule discovery engine, and regulation engine belongs to the application configuration system; The rule discovery engine refers to find certain rule in business procedure to belong to the pattern-recognition category by pattern match.
Regulation engine comprises following part: the application program of rule script (not needing compiling), regulation engine framework, calling rule engine.The general rule script comprises: carry out body and rule body, rule body comprises trigger condition and calling execution body and need manner of execution.
Workflow (workflow) refers to a series of front and back continuous step that is connected mutually.Relation between these steps of expression such as the script that workflow engine (workflow engine) use is understandable, the workflow engine framework reads and explains these steps, during use, application program is carried out corresponding work flow step by the workflow engine interface interchange, and obtains result.Workflow engine has separated workflow and concrete programming.
Parallel computation in the present invention (operation) refers to, because data are distributed in different logical addresses, need to go by identical or different subroutine module to operate respectively, the combination of the subroutine that these are different or different logical addresses is called branch, single job (calculating) to data, need to go to select from one or more possible branches, operation (or claiming to calculate) spatially walks abreast, and therefore is called parallel computation.
Business Rule Engine and workflow engine have been realized the effective configuration to system's variable portion substantially, but also the scheme engine can be not convenient preferably at present, realizes fast the effective support to parallel computations such as system data back-up, conjunctive queries.
Summary of the invention
In order to have filled up Business Rule Engine in the blank aspect parallel computation, the concurrent service regulation engine uses the executed in parallel body in configuration file.A parallel work-flow of data can be by using different subroutines or using different logical addresses to reach, and the combination of the subroutine that the invention China invites the person is different with these or different logical addresses is called branch.
The executed in parallel body has two kinds of modes of operation to data: data read, and data write (comprise and revise deletion).Data read branch's selection modes such as comprising associating, selection, competition: unite that to read be exactly reading out data from a series of branches, be assembled at last result set; Selection supposes that each branch data is the same, carries out body (at random) from branch and selects branch's reading result collection; Competition supposes that each branch data is the same, carries out body and reads from each branch, but only get that the fastest part, and remaining abandons.Data write and comprise associating, wait branch's selection mode simultaneously: unite exactly data to be broken according to rule and be put in each branch, what each branch obtained is incomplete data, but the summation of all branch datas is partial datas; Exactly data are not broken simultaneously, complete is saved in each branch.
Searching with create-rule of branch is: branch address or subroutine title are to be obtained by mapping by the parameter that engine imports into, and the parameter value that participates in mapping can be " " or null.Mapping ruler is, be provided with i variable, { Xi} is the set of these variablees, and branch address or subroutine name are called F ({ Xi}), find out so a F ({ Xi}), by F ({ Xi}) can obtain by inverse mapping in Xi} required partly or entirely.This rule engine is by the variable mapping ruler rather than select branch by condition judgment, thereby obtains the support to the several data read-write mode, and this is feature of the present invention.
Parallel computation realizes by the executed in parallel body, and executed in parallel body parameter has three types: constant, the variable that imports into during by application call regulation engine framework, the parameter that is got by constant and other Parameter Mappings.Method or carry out the mode that body quotes and have two kinds: constant method, the method for being come by constant and other Parameter Mappings.The third Type mapping of executed in parallel body logical address branch, in the executed in parallel body, the second way of reference of method or executed in parallel body has been shone upon subroutine branch.
Because the executed in parallel body is by mapping but not condition judgment is selected branch, therefore, the solution of the present invention can be applicable to workflow engine.Specifically: the executed in parallel body is as an XM of workflow engine; A upper node of workflow engine or the caller of this section workflow engine import corresponding parameter into, and call this node; Then each branch of this node mapping returns to net result to next node; If this is last node of engine, that just returns to the caller of workflow engine.
Embodiment
The realization of Business Rule Engine has following steps:
1. regulation engine need to lean on the regulation engine framework to explain execution, and application program is read in the regulation engine framework.
2. in configuration file, configuration service is regular, and application program is read in configuration file, and explains these rules by framework.
3. application program by to the calling of framework SPI, and is imported corresponding parameter into corresponding local, and executing rule obtains result at last.
4. if program changes in this corresponding local requirement rules, as long as parameter constant, the programmer just can be effective by reconfiguring business rule.
The layoutprocedure of concurrent service regulation engine and concurrent service workflow engine is as follows:
1. at first define the method for the program that needs invoked branch, if the different execution bodies that just further the method are encapsulated as of the method for branched program.
2. define the executed in parallel body, the executed in parallel body is claimed as and reads or write type, and mode is united, selects, competes, waited simultaneously in statement.
In the executed in parallel body configuration import parameter into, to " method and carry out quoting of body ".The type of parameter and " method or execution body are quoted " can be generated by mapping, and the result of mapping can be used as parameter; Perhaps as the title of the execution body of step 1 definition, further obtain parameter by carrying out body; Perhaps quoted by " method or carry out body and quote " institute as the title of the execution body of step 1 definition.
4. the application call engine framework, carry out the executed in parallel body, does parallel work-flow.
Below in conjunction with concrete application scenarios, further illustrate the present invention, the present invention can be applied to but be not limited to following situation:
Suppose that log system needs journal file of every large generation, and can check the daily record of all days.
The developer can develop in accordance with the following steps and configure:
1. general method of compiling in program, be used for writing daily record, if do not have corresponding journal file just to generate journal file.
2. configuration executed in parallel body 1, be used for journal file is carried out parallel work-flow." method or carry out body quote " partial configuration of executed in parallel body is for to the quoting of the method for step 1, and imports parameter into consistent with parameter in step 1.
3. executed in parallel body 1 is for writing type, and is claimed as simultaneous system, to adapt to the demand that is written in parallel to.
4. the journal file name parameter in executed in parallel body 1 configures with mapping mode, and the mapping formula is F (X)=Log|MMDD, and MM is the moon, and DD is day; MM and DD import into as preset parameter respectively, the expression current time, therefore, a fixing branch are only carried out in each write operation of executed in parallel body 1.
5. general method of compiling in program, be used for reading daily record.
6. configuration executed in parallel body 2, be used for journal file is carried out parallel work-flow." method or carry out body quote " partial configuration of executed in parallel body is for to the quoting of the method for step 1, and imports parameter into consistent with parameter in step 1.
7. the journal file name parameter in executed in parallel body 2 configures with mapping mode, and the mapping formula is F (X)=Log|MMDD, and MM is the moon, and DD is day.
8. executed in parallel body 2 is for reading type, and is claimed as associated form, to adapt to from the demand of each branch's conjunctive query data.
Suppose that application system need to access two databases, these two data database datas are just the same, and one is used for backup, and one is used for doing the regular traffic access; Two databases only have the address different.
The developer can develop in accordance with the following steps and configure:
1. first configure two and carry out body in the engine script, return to respectively the address of two databases, suppose that now carrying out the body name for these two is called DB0001 and DB0002;
2. general method of compiling in program, be used for two databases are carried out read operation, and the parameter of the method should comprise database address.
3. configure executed in parallel body 1, for read operation that two databases are walked abreast." method or carry out body quote " partial configuration of executed in parallel body is for to the quoting of the method for step 2, and imports parameter into consistent with parameter in step 2.
4. the database address parameter in parallel rule body 1 is configured to carrying out quoting of body DB000X, and the execution body title of quoting gets (as step 1) by mapping F (X)=DB|000X.
5. executed in parallel body 1 is chosen as and reads type, is claimed as selection mode, to adapt to the demand of reading a branch data from backup.
6. general method of compiling in program, be used for two databases are carried out write operation, and the parameter of the method should comprise database address.
7. configuration executed in parallel body 2, be used for two databases are written in parallel to operation." method or carry out body quote " partial configuration of executed in parallel body is for to the quoting of the method for step 2, and imports parameter into consistent with parameter in step 6.
8. the database address parameter in parallel rule body 2 is configured to carrying out quoting of body DB000X, and the execution body title of quoting gets (as step 1) by mapping F (X)=DB|000X.
9. executed in parallel body 2 is chosen as and writes type, is claimed as simultaneous system, to adapt to the demand of reading a branch data from backup.
Robbing bill system buys tickets from different companies respectively, suppose N company, system of every company booking interface parameters form and return data be the same (perhaps can converting to) all, be that concrete implementation method is different, rob first ticket that bill system need to obtain to buy, if after getting a ticket, remaining ticket is all removed singly and is abandoned.
The developer can develop in accordance with the following steps and configure:
1. first configure N and carry out body in the regulation engine script, parameter is the interface parameters of each system of company, and implementation method is respectively the implementation method of each system of company, carries out the body name and is called ZXT1 to ZXTN.
2. configuration executed in parallel body is used for the parallel booking operation to this N company.Because the parameter format of this N company is all consistent, therefore, the parameter of the parameter synchronization of executed in parallel body rapid 1 is the same.
3. " method or execution body are quoted " partial configuration of executed in parallel body is for carrying out quoting of body to N.The execution body title of quoting gets (seeing step 1) by mapping F (X)=ZXT|N.
4. executed in parallel body selective rule is claimed as the competition reading manner, competes inquiry to adapt to from each branch, thereby obtains the soonest the demand of ticket.