Specific implementation mode
Before the scheme that this specification offer is provided, first following optimum ideals are provided in conjunction with traditional technology:
The information exchange figure of distributed transaction processing method shown in FIG. 1 can be as shown in Figure 2.Figure it is seen that
Pretreatment stage, the substantially uninevitable dependence of calling of the task manager to each participant.In addition, either existing
Presentation stage is still in rollback phase, above-mentioned calling process also not no inevitable dependence.Therefore, in distributed environment,
Calling of the task manager between each participant is to may be used what concurrent mode carried out.Namely each branch's affairs are
It can be with parallel processing.By above-mentioned parallel form, in the case where participant is more, the time of distributing real time system is simultaneously
It will not be linearly increasing.For example, if a service interaction time is T, in the case of having N number of participant, according to tradition
Distributing real time system mode, the processing expense in two stages is all NT.And parallel form is used, it being capable of basic guarantee
Processing time is T.
With reference to above-mentioned optimum ideals, the scheme provided this specification is described in detail.
The distributed transaction processing method that this specification one embodiment provides can be applied to scene as shown in Figure 3
In, in Fig. 3, operation system is used to, according to service request, distributed transaction is divided into multiple branch's affairs.Branch's thing herein
Business can refer to a behavior of distributed transaction.It is with business demand:Come for " transferring accounts 100 yuan to account B from account A "
It says, then distributed transaction can be divided into Liang Ge branches affairs, which is respectively used to be handled as follows:“A-
100 " and " B+100 ".Later, multiple branch's affairs of division can be sent to task manager by operation system.Transaction management
Device can parse multiple branch's affairs, after receiving above-mentioned multiple branch's affairs with the respective processing of determination
Object (e.g., account etc.) and the processing mode to dealing with objects corresponding resource (e.g., account balance, gold etc.).Later, may be used
According to process object and processing mode, to determine the dependence between multiple branch's affairs.And according to the dependence, parallel
And/or the multiple branch's affairs of serial process.Finally, the processing result information of multiple branch's affairs is returned to industry by task manager
Business system.
It should be noted that in Fig. 3, task manager handles branch's affairs particular by participant is called,
In, participant can refer to the service that task manager is called when handling branch's affairs.Such as previous example, a participant
Financial library A is may be considered, and another participant may be considered financial library B.Specifically, in above-mentioned two branch affairs
In processing procedure, task manager can call financial library A to produce 100 yuan from account A, and financial library B can be called to give account B
It is transferred to 100 yuan.Account A has just been protected as a result, and has been withholdd adds the consistency of money with account B.In the processing procedure of above-mentioned branch's affairs,
If having any exception, unsuccessfully rollback, and feeds back and transfer accounts unsuccessfully.
Fig. 4 is the distributed transaction processing method flow chart that this specification one embodiment provides.The execution of the method
Main body can be the task manager in Fig. 3.As shown in figure 4, the method can specifically include:
Step 410, task manager obtains the corresponding multiple branch's affairs of distributed transaction.
In one implementation, distributed transaction can be divided into multiple branches by operation system according to business demand
Affairs.It is with business demand:It " transfers accounts 100 yuan to account B from account A, 5 yuan is shared in the benefit to for for account C ", then from account B
Distributed transaction can be divided into four branch's affairs, which is respectively used to be handled as follows:“A-100”、
" B+100 ", " B-5 " and " C+5 ".Later, multiple branch's affairs of division can be sent to task manager by operation system.
Step 420, multiple branch's affairs are parsed, with the multiple branch's affairs of determination it is respective process object and it is right
Deal with objects the processing mode of corresponding resource.
Process object herein may include the account etc. of user.Corresponding resource is dealt with objects to can include but is not limited to
Account balance (also referred to as fund) and gold etc..And may include that resource increases to the processing mode for dealing with objects corresponding resource
With resource consumption etc..To deal with objects as account, deal with objects corresponding resource be account balance for for, can be according to right
The increase and decrease situation of the account balance of account determines the processing mode to resource.Specifically, when increasing the account balance in account
When, can be that resource increases to the processing mode of resource;And when reducing the account balance in account, to the processing mode of resource
It can be resource consumption.
Such as previous example, the respective process object of four branch's affairs is respectively:" account A ", " account B ", " account B " and
" account C ".Further, since first branch's affairs is used to deduct 100 yuan namely the first point from the account balance of account A
Branch affairs are used to reduce the account balance in account A, so it is to the processing mode of resource:" resource consumption ".It similarly can be with
Determine that other three branch's affairs are respectively to the processing mode of resource:, " resource increase ", " resource consumption " and " resource increase
Add ".
Step 430, according to process object and processing mode, the dependence between multiple branch's affairs is determined.
In one implementation, can be classified to multiple branch's affairs according to processing mode.To branch's affairs
After being classified, according to process object, the dependence between different classes of branch's affairs is determined.Specifically, to multiple points
Each branch's affairs in branch affairs judge whether branch's affairs are resource to the processing mode for dealing with objects corresponding resource
Increase.If so, determining that the classification of branch's affairs is that resource increases class.If not, it is determined that the classification of branch's affairs is money
Source consumes class.Increase resource branch's affairs of class, directly can be determined as being not present relying on by branch's affairs of the category and close
Branch's affairs of system.To branch's affairs of resource consumption class, judge branch's affairs of the resource consumption class process object whether
It is identical to increase the process object of branch's affairs of class with resource.If so, determining that branch's affairs of the resource consumption class are to exist
Branch's affairs of dependence.If not, it is determined that branch's affairs of the resource consumption class are that there is no branch's things of dependence
Business.
Such as previous example, due to second branch's affairs (the branch's affairs for corresponding to " B+100 ") and the 4th branch's thing
Business (the branch's affairs for corresponding to " C+5 ") is " resource increase " to the processing mode for dealing with objects corresponding resource, so can
To determine that the classification of the Liang Ge branches affairs increases class as resource.Since first branch's affairs (corresponds to the branch of " A-100 "
Affairs) and third branch affairs branch's affairs of (correspond to " B-5 ") it is equal to the processing mode for dealing with objects corresponding resource
For " resource consumption ", it is possible to determine that the classification of the Liang Ge branches affairs is resource consumption class.
Increase the Liang Ge branches affairs of class for resource, it may be determined that the Liang Ge branches affairs are that there is no dependences
Branch's affairs.To the Liang Ge branches affairs of resource consumption class, due to the processing of third branch affairs and second branch's affairs
Object (account B) is identical, it is possible to determine that third branch affairs are branch's affairs there are dependence.And the first point
Branch affairs and the process object for the Liang Ge branches affairs that resource increases class are different, so determining that first branch's affairs is not deposit
In branch's affairs of dependence.
Step 440, according to dependence, the parallel and/or multiple branch's affairs of serial process.
In one implementation, the branch's affairs that can will be not present dependence are divided into the first grouping, there will be
Branch's affairs of dependence are divided into second group.Branch's affairs in the grouping of parallel processing first.Point in the first grouping
After branch end of transaction, branch's affairs in parallel processing second packet.
Such as previous example, second branch's affairs, the 4th branch's affairs and first branch's affairs can be divided
To the first grouping.Third branch affairs are divided into second packet.Later, second branch's affairs of parallel processing, the 4th
Branch's affairs and first branch's affairs.After three branch's end of transaction, processing third branch affairs.This
Place, it is understood that be that third branch affairs are serial process.
The distributed transaction processing method provided by this specification above-described embodiment can both improve distributed transaction
Treatment effeciency, and can guarantee the correctness of its processing.Such as previous example, in point corresponding to " A-100 ", " B+100 " and " C+5 "
The parallel processing of branch affairs elder generation can correspond to later in the case where serial process corresponds to " B-5 " branch's affairs to avoid working as
When " B-5 " branch affairs are first handled, if the account balance of account B be 0, can processing failure the problem of.That is, this specification
It, can be by way of setting processing sequence, to ensure its processing when the process object of branch's affairs is identical in embodiment
Correctness.
It is understood that in the transaction methods that this specification above-described embodiment provides, it is assumed that task manager
It is T to call the time of primary service (or participant), and assumes that distributed transaction is divided into N number of branch's affairs.So in N
There is no in the case of dependence between a branch's affairs, the processing time expense of distributed transaction is T.And in N number of branch
Between affairs there are dependence in the case of, the processing time expense of distributed transaction is 2T.Thus, it is possible to find out, dividing
In the case that dependence is not present in cloth affairs, the scheme that this specification provides can be by distributing real time system time control
Within the scope of single branch's transaction time, because participant increases will not be increased the entire distributing real time system time
Add.Even if in the case of there is dependence between branch's affairs, handling duration is still controllable, and not with participant's popularization
And processing time is caused to increase.
Accordingly with above-mentioned distributed transaction processing method, a kind of distributed thing that this specification one embodiment also provides
Business processing unit, as shown in figure 5, the device includes:
Acquiring unit 501, for obtaining the corresponding multiple branch's affairs of distributed transaction.
Resolution unit 502, for being parsed to multiple branch's affairs that acquiring unit 501 obtains, with multiple points of determination
The respective process object of branch affairs and the processing mode to dealing with objects corresponding resource.
Herein, process object can be the account etc. of user.It can be account balance etc. to deal with objects corresponding resource.
Determination unit 503 determines multiple for parsing obtained process object and processing mode according to resolution unit 502
Dependence between branch's affairs.
Optionally it is determined that unit 503 specifically can be used for:
According to processing mode, classify to multiple branch's affairs;
According to process object, the dependence between different classes of branch's affairs is determined.
Optionally it is determined that unit 503 also specifically can be used for:
To each branch's affairs in multiple branch's affairs, processing of branch's affairs to the corresponding resource of process object is judged
Whether mode is that resource increases.
If so, determining that the classification of branch's affairs is that resource increases class.
If not, it is determined that the classification of branch's affairs is resource consumption class.
Branch's affairs that resource is increased to class are determined as that branch's affairs of dependence are not present.
To branch's affairs of resource consumption class, judge whether the process object of branch's affairs of resource consumption class increases with resource
Add the process object of branch's affairs of class identical.
If so, determining that branch's affairs of resource consumption class are branch's affairs there are dependence.
If not, it is determined that branch's affairs of resource consumption class are that there is no branch's affairs of dependence.
Processing unit 504, the dependence for being determined according to determination unit 503, parallel and/or multiple points of serial process
Branch affairs.
Optionally, processing unit 504 specifically can be used for:
There will be no branch's affairs of dependence to be divided into the first grouping, and there will be branch's affairs of dependence to divide
To second group.
Branch's affairs in the grouping of parallel processing first.
After branch's end of transaction in the first grouping, branch's affairs in parallel processing second packet.
The function of each function module of this specification above-described embodiment device can pass through each step of above method embodiment
Rapid to realize, therefore, the specific work process for the device that this specification one embodiment provides does not repeat again herein.
The distributing real time system device that this specification one embodiment provides, acquiring unit 501 obtain distributed transaction
Corresponding multiple branch's affairs.Resolution unit 502 parses multiple branch's affairs, respective with the multiple branch's affairs of determination
Process object and the processing mode to dealing with objects corresponding resource.Determination unit 503 according to process object and processing mode,
Determine the dependence between multiple branch's affairs.For processing unit 504 according to dependence, parallel and/or serial process is multiple
Branch's affairs.Thus, it is possible to improve the treatment effeciency of distributed transaction.
Those skilled in the art are it will be appreciated that in said one or multiple examples, described in this specification
Function can be realized with hardware, software, firmware or their arbitrary combination.It when implemented in software, can be by these work(
Can storage in computer-readable medium or as on computer-readable medium one or more instructions or code passed
It is defeated.
Above-described specific implementation mode has carried out into one the purpose, technical solution and advantageous effect of this specification
Step is described in detail, it should be understood that the foregoing is merely the specific implementation mode of this specification, is not used to limit this
The protection domain of specification, all any modifications on the basis of the technical solution of this specification, made, change equivalent replacement
Into etc., it should all be included within the protection domain of this specification.