In prior art, by using two-phase commitment protocol to carry out the process of affairs, this agreement is specifically wrapped
Include: 1) pretreatment stage, affairs coordinator sends pretreatment asks to the participant related in issued transaction,
Notify that they prepare to submit data to;2) rollback phase, if affairs coordinator does not receives a certain participation always
The response of person or have arbitrary participant to make negative response, i.e. represents that this participant prepares failure, then by one
Rollback request is sent to all participants so that in data base, all data about these affairs are recovered to affairs
State before processing.
But, in the prior art, if having participant owing to transaction capabilities is poor or network jitter etc. is former
Cause, failed always pretreatment request, and complete rollback request Concurrency go out rollback ask respond after,
Just complete pretreatment request, then this participant follow-up can be caused to be constantly in SBR, and affairs coordinator
Then because of have received the rollback of participant complete response after, be mistakenly considered the equal rollback of participant and complete so that affairs
Concordance is destroyed, cause in data base about these affairs data will complete confusion and unpredictable,
Data base is caused normally to use.
To sum up, issued transaction of the prior art also exists the problem that transaction consistency is difficult to ensure that.
Application content
The embodiment of the present application provides a kind of transaction methods and device, solves issued transaction in prior art
During the technical problem that is difficult to ensure that of concordance.
The embodiment of the present application also provides for a kind of transaction methods, comprising:
Obtaining the first request of pending affairs, described first request is asked for pretreatment;
Judging whether the second request of described pending affairs meets pre-conditioned, described second request is rollback
Request;
If so, described first request is terminated;If it is not, perform described first request.
The embodiment of the present application also provides for a kind of transaction methods, comprising:
Obtaining the first request of pending affairs, described first request is asked for rollback;
Judging whether the second request of described pending affairs meets pre-conditioned, described second request is pre-place
Reason request;
If so, described first request is terminated;If it is not, perform described first request.
The embodiment of the present application also provides for a kind of transacter, comprising:
Acquisition module, for obtaining the first request of pending affairs, described first request is asked for pretreatment;
Judge module, for judging whether the second request of described pending affairs meets pre-conditioned, described
Second request is asked for rollback;
Perform module, if described second request meets pre-conditioned, be used for terminating described first request, if institute
Second request of stating does not meets pre-conditioned, is used for performing described first request.
The embodiment of the present application also provides for a kind of transacter, comprising:
Acquisition module, for obtaining the first request of pending affairs, described first request is asked for rollback;
Judge module, for judging whether the second request of described pending affairs meets pre-conditioned, described
Second request is asked for pretreatment;
Perform module, if described second request meets pre-conditioned, be used for terminating described first request, if institute
Second request of stating does not meets pre-conditioned, is used for performing described first request.
At least one technical scheme above-mentioned that the embodiment of the present application uses can reach following beneficial effect:
In the embodiment of the present application, whether meet pre-conditioned deciding whether according to the second request and terminate just to obtain
The first request arrived, no matter the first request is pretreatment request or rollback request, all can realize rollback request
Being performed rear pretreatment request will not be performed, pretreatment request is performed rear rollback request and just can perform;Keep away
Exempt from pretreatment request after rollback is asked, complete to destroy the concordance of affairs, it is ensured that about this in data base
The correctness of the data of affairs.
Detailed description of the invention
For making the purpose of the application, technical scheme and advantage clearer, specifically real below in conjunction with the application
Execute example and technical scheme is clearly and completely described by corresponding accompanying drawing.Obviously, described
Embodiment is only some embodiments of the present application rather than whole embodiments.Based on the enforcement in the application
Example, the every other enforcement that those of ordinary skill in the art are obtained under not making creative work premise
Example, broadly falls into the scope of the application protection.
In affairs in processing procedure, it is understood that there may be pretreatment request just terminates to cause after rollback has been asked
The situation that transaction consistency is destroyed, for ensureing the concordance of affairs, the embodiment of the present application provides a kind of affairs
Processing method, is discussed in detail this method below in conjunction with accompanying drawing.
The process of the transaction methods that Fig. 1 provides for the embodiment of the present application, comprises the steps:
S10, obtain pending affairs first request.
In embodiments herein, the first request refers to the pretreatment request of affairs, is used for notifying that participant is accurate
Standby submission data.
Generally submit to the action of data all along with the transfer of affairs related data, such as, pass through Web bank
Interior remaining sum account carries out net purchase payment for goods payment, and this payment process is affairs.First, buyer's is online
After bank balance account obtains pretreatment request, payment for goods is gone to trustship account, is successfully stored in trustship in payment for goods
After account, it is considered as remaining sum account and completes pretreatment request;Follow-up, payment for goods is committed to sell from trustship account again
Family's account, thus complete whole payment for goods and pay.
S20, judge whether the second request of these pending affairs meets pre-conditioned, if so, perform step
S30;If it is not, perform step S40.
Wherein, the second request is asked for rollback, and this is pre-conditioned is: the second request (rollback request) is being located
In reason or the most treated complete.
S30, terminate this first request, and to management issued transaction affairs coordinator send pretreatment request
Failure response.
S40, perform this first request.
As a example by Web bank, remaining sum account carries out net purchase payment for goods payment equally, remaining sum account obtains pre-place
After reason request, if remaining sum account transaction disposal ability and network capacity are all normal, remaining sum account performs
During pretreatment request, rollback request does not generate, and natural rollback request does not meets that it is pre-conditioned yet, now,
Continue executing with the first request, to promote whole issued transaction process.
But, when remaining sum account disposal ability is poor or network jitter is bigger, remaining sum account is being successfully received
After rollback request, start to perform rollback request when even completing rollback request, just get pretreatment and ask;
Now, because rollback request meets pre-conditioned, pretreatment request is directly terminated, it is to avoid continue executing with pretreatment
The consistent affairs sex chromosome mosaicism that request causes, it is ensured that the correctness of the interior data about these affairs of data base.
For the embodiment of the present application, Fig. 2 provides whether the rollback judging pending affairs in transaction methods asks
Meeting pre-conditioned detailed process figure, this step S20 includes:
S21a, generating the transaction information of pending affairs, transaction information includes Transaction Identifier and transaction status.
In embodiments herein, obtaining transaction request, no matter this transaction request is pre-place every time
Reason request or rollback request, all can generate the transaction information of pending affairs.
In transaction information, can to pass through affairs content, affairs participant and affairs initiation time etc. many for Transaction Identifier
Individual because usually defining, unrelated with the type of transactions requests so that during each issued transaction, these affairs
Transaction information there is unique Transaction Identifier.
In transaction information, transaction status is normal or rollback, and when obtaining pretreatment request, transaction status is then marked
For normally;When obtaining rollback request, transaction status is then designated as rollback.
S22a, judge to have recorded the transaction information summary table of transaction information in whether exist and the thing of pending affairs
The transaction information that business mark is identical, if it is not, perform S23a, if so, performs S24a.
In embodiments herein, it is provided that a transaction information summary table, after generating transaction information, all should every time
The transaction information of affairs is stored in transaction information summary table.Transaction Identifier is done data integrity by transaction information summary table
Constraint so that issued transaction the most only has unique transaction information every time.
After the transaction request obtaining pending affairs, the transaction information of pending affairs is inserted affairs
According to being successively inserted into, information summary table, determines whether that existence is identical with the Transaction Identifier of pending affairs
Transaction information.
If occurring inserting unsuccessfully, then there is the Transaction Identifier phase with pending affairs in judging transaction information summary table
Same transaction information, otherwise, then there is not, in judging transaction information summary table, the transaction information that Transaction Identifier is identical,
The transaction information of the most pending affairs is inserted in transaction information summary table, completes to transaction information summary table more
Newly.
Certainly, in other embodiments of the application, also by the Transaction Identifier of the pending affairs of extraction, look into
Ask transaction information summary table, it is judged that whether this Transaction Identifier is contained therein, in realizing transaction information summary table to be
The transaction information that no existence is identical with the Transaction Identifier of pending affairs, does not repeats at this.
S23a, it is determined that the presence of identical transaction information, i.e. rollback request does not meets pre-conditioned.
When there is not the transaction information identical with the Transaction Identifier of pending affairs in transaction information summary table, table
The pretreatment of these pending affairs bright is asked as to ask first, can continue executing with this pretreatment request.
Whether the transaction status of the transaction information that S24a, judgement are stored in transaction information summary table is rollback, if it is not,
Perform S25a, if so, perform S26a.
If there is the transaction information identical with the Transaction Identifier of pending affairs in transaction information summary table, show this
The first treated request of secondary transaction request not these affairs, is recorded in transaction information summary table by judgement
Whether the transaction status of transaction information is rollback, carrys out the currently processed progress of clearly these affairs.
When the transaction status of transaction information is rollback in transaction information summary table, show that this issued transaction has arrived
Rollback phase, now, it is determined that the rollback request of these affairs is processing or processed;Otherwise, if
In transaction information summary table, the transaction status of transaction information is normal, shows that this issued transaction is also in pretreatment rank
Section, the most single transactions requests participant does repeatedly pretreatment request, can continue executing with current pretreatment
Request.
S25a, judgement rollback request do not meet pre-conditioned.
S26a, judgement rollback are asked in processes or the most treated complete, i.e. rollback request meets pre-conditioned.
In embodiments herein, transaction methods also includes: when pending affairs are submitted to successfully, delete
Except the transaction information of these pending affairs, reduce transaction information summary table and take up room, the most also improve affairs mark
Know search efficiency.
The process of the transaction methods that another embodiment of the application provides, with issued transaction in previous embodiment
The process of method is compared, and difference is: the first request is asked for rollback, and the second request is asked for pretreatment,
Pre-conditioned it is: pretreatment is asked in processes.
Fig. 3 provides the rollback request judging pending affairs in transaction methods for another embodiment of the application
Whether meeting pre-conditioned detailed process figure, step S20 includes:
S21b, generating the transaction information of pending affairs, transaction information includes Transaction Identifier and transaction status.
S22b, judge to have recorded the transaction information summary table of transaction information in whether exist and the thing of pending affairs
The transaction information that business mark is identical, if so, performs S23b, if it is not, perform S24b.
S23b, it is determined that the presence of identical transaction information, i.e. pretreatment request does not meets pre-conditioned.
S24b, judge whether the transaction information of pending affairs to be inserted into transaction information summary table, if so,
Perform S25b, if it is not, perform S26b.
In transaction information summary table, there is not the transaction information with pending affairs same transaction mark exist,
And the transaction information of pending affairs is when also cannot insert transaction information summary table, before showing, affairs participant will
The action that the transaction information generated when obtaining pretreatment request inserts transaction information summary table is the most underway.
Now so that in transaction information summary table, there is not the transaction information of this things identical mark, affairs participate in
The transaction information generated when obtaining rollback request cannot be also inserted in transaction information summary table by person, and then obtains
Pretreatment request conclusion in processes.
S25b, judgement transaction information insert unsuccessfully, i.e. pretreatment request does not meets pre-conditioned.
S26b, judgement pretreatment are asked in processes, i.e. preset process request and meet pre-conditioned.
Ask when pretreatment is asked in processes by setting pretreatment, terminate rollback request, and to management
The affairs coordinator of issued transaction sends rollback request failure response.Affairs coordinator waits after presetting time delay,
Sending rollback request to affairs participant again, affairs participant repeats aforementioned execution step S21b-S26b, directly
To obtain pretreatment request processed or process make mistakes.
Owing to, after completing pretreatment request, rollback request could be performed;Avoid pretreatment to ask in rollback
Request just completes after terminating, it is ensured that the correctness of the interior data about these affairs of data base.
In embodiments herein, transaction methods also includes: when pending transaction rollback success, will
The transaction status of pending affairs is updated to rollback.
If before rollback request performs, have been carried out the pretreatment request of these affairs or perform pretreatment request
Abnormal, in transaction information summary table, there is the transaction information of these pending affairs, and has been stored in transaction information
The transaction status of the transaction information of the pending affairs in summary table is normal, then after rollback completes, by this thing
Business state is by normally changing rollback into.
If before rollback request performs, the pretreatment request of these affairs is not carried out, then given birth to when rollback being asked
The transaction status of the transaction information become directly is updated to rollback.
The structural scheme of mechanism of the transacter that Fig. 4 provides for the embodiment of the present application, the embodiment of the present application institute
The transacter provided is based on above transaction methods, therefore the detail of this device can refer to above
Processing method, is the most no longer repeated.This transacter includes:
Acquisition module 10, for obtaining the first request of pending affairs.
Judge module 20, for judging whether the second request of pending affairs meets pre-conditioned.
Perform module 30, if the second request meets pre-conditioned, for terminating the first request, if the second request
Do not meet pre-conditioned, for performing the first request.
In the embodiment of the present application, the first request is pretreatment request, and the second request is rollback request;Preset bar
Part is: rollback is asked in processes or the most treated complete.
In the embodiment of the present application, it is judged that module 20 specifically includes:
Information generating unit, generates the transaction information of pending affairs, and transaction information includes Transaction Identifier and thing
Business state.
Whether mark judging unit, exist the affairs mark with pending affairs in judging transaction information summary table
Sensible same transaction information.
Condition adjudgement unit, if there is the transaction information that Transaction Identifier is identical, is stored in transaction information for judgement
Whether the transaction status of the transaction information in summary table is rollback, if transaction status is rollback, it is determined that the second request
In processes or the most treated complete.
In the embodiment of the present application, mark judging unit specifically for:
The transaction information of pending affairs is inserted transaction information summary table.
Determine whether that Transaction Identifier repeats abnormal, if it is not, it is determined that the presence of and the Transaction Identifier of pending affairs
Identical transaction information.
In the embodiment of the present application, transacter also includes:
Information deletion module, for when pending affairs are submitted to successfully, deletes the affairs of these pending affairs
Information.
In the embodiment of the present application, the first request is rollback request, and the second request is pretreatment request;Preset bar
Part is: the second request is in processes.
In the embodiment of the present application, it is judged that module 20 specifically includes:
Information generating unit, for generating the transaction information of pending affairs, transaction information includes Transaction Identifier
And transaction status.
Whether mark judging unit, exist the affairs mark with pending affairs in judging transaction information summary table
Sensible same transaction information.
Inserting judging unit, if there is not the transaction information that Transaction Identifier is identical, being used for judging whether can be by
The transaction information of pending affairs is inserted into transaction information summary table, if transaction information inserts unsuccessfully, it is determined that second
Request is in processes.
In the embodiment of the present application, insert judging unit specifically for:
The transaction information of pending affairs is inserted transaction information summary table.
Determine whether that Transaction Identifier repeats abnormal, if it is not, it is determined that the presence of and the Transaction Identifier of pending affairs
Identical transaction information.
In the embodiment of the present application, transacter also includes:
Rollback more new module, for when pending transaction rollback success, by the transaction status of pending affairs
It is updated to rollback.
In the embodiment of the present application, transacter also includes responding sending module, for sending the first request
Failure response.
Whether the transacter that the embodiment of the present application is provided, meet pre-conditioned next according to the second request
Deciding whether to terminate the first request just got, no matter the first request is that pretreatment request or rollback please
Ask, all can realize rollback request be performed rear pretreatment request will not be performed, pretreatment request be performed after
Rollback request just can perform;Pretreatment request is avoided to complete to destroy the concordance of affairs after rollback is asked,
Ensure that the correctness of the interior data about these affairs of data base.
It should be noted that the executive agent of each step of the provided transaction methods of embodiments herein
May each be same equipment, or, the method also by distinct device as executive agent.Such as, step 21
Can be equipment 1 with the executive agent of step 22, the executive agent of step 23 can be equipment 2;Again than
As, the executive agent of step 21 can be the executive agent of equipment 1, step 22 and step 23 can be to set
Standby 2.
Those skilled in the art are it should be appreciated that embodiments herein can be provided as method, device or meter
Calculation machine program product.Therefore, the application can use complete hardware embodiment, complete software implementation or knot
The form of the embodiment in terms of conjunction software and hardware.And, the application can use and wherein wrap one or more
Computer-usable storage medium containing computer usable program code (include but not limited to disk memory,
CD-ROM, optical memory etc.) form of the upper computer program implemented.
The application is with reference to method, equipment (device) and the computer program product according to the embodiment of the present application
The flow chart of product and/or block diagram describe.It should be understood that can by computer program instructions flowchart and
/ or block diagram in each flow process and/or flow process in square frame and flow chart and/or block diagram and/
Or the combination of square frame.These computer program instructions can be provided to general purpose computer, special-purpose computer, embedding
The processor of formula datatron or other transaction facilities able to programme is to produce a machine so that by calculating
The instruction that the processor of machine or other transaction facilities able to programme performs produces for realizing at flow chart one
The device of the function specified in individual flow process or multiple flow process and/or one square frame of block diagram or multiple square frame.
These computer program instructions may be alternatively stored in and computer or other issued transaction able to programme can be guided to set
In the standby computer-readable memory worked in a specific way so that be stored in this computer-readable memory
Instruction produce and include the manufacture of command device, this command device realizes in one flow process or multiple of flow chart
The function specified in flow process and/or one square frame of block diagram or multiple square frame.
These computer program instructions also can be loaded on computer or other transaction facilities able to programme, makes
Sequence of operations step must be performed to produce computer implemented place on computer or other programmable devices
Reason, thus the instruction performed on computer or other programmable devices provides for realizing flow chart one
The step of the function specified in flow process or multiple flow process and/or one square frame of block diagram or multiple square frame.
In a typical configuration, calculating equipment includes one or more processor (CPU), input/defeated
Outgoing interface, network interface and internal memory.
Internal memory potentially includes the volatile memory in computer-readable medium, random access memory
(RAM) and/or the form such as Nonvolatile memory, such as read only memory (ROM) or flash memory (flash RAM).
Internal memory is the example of computer-readable medium.
Computer-readable medium includes that removable media permanent and non-permanent, removable and non-can be by appointing
Where method or technology realize information storage.Information can be computer-readable instruction, transaction structure, program
Module or other affairs.The example of the storage medium of computer includes, but are not limited to phase transition internal memory
(PRAM), static RAM (SRAM), dynamic random access memory (DRAM), its
The random access memory (RAM) of his type, read only memory (ROM), electrically erasable are read-only
Memorizer (EEPROM), fast flash memory bank or other memory techniques, read-only optical disc read only memory
(CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tape, tape magnetic
Disk storage or other magnetic storage apparatus or any other non-transmission medium, can be used for storage can be calculated
The information that equipment accesses.According to defining herein, computer-readable medium does not include temporary computer-readable matchmaker
Body (transitory media), such as transaction signals and the carrier wave of modulation.
Also, it should be noted term " includes ", " comprising " or its any other variant are intended to non-
Comprising of exclusiveness, so that include that the process of a series of key element, method, commodity or equipment not only wrap
Include those key elements, but also include other key elements being not expressly set out, or also include for this process,
The key element that method, commodity or equipment are intrinsic.In the case of there is no more restriction, statement " include
One ... " key element that limits, it is not excluded that including the process of described key element, method, commodity or setting
Other identical element is there is also in Bei.
It will be understood by those skilled in the art that embodiments herein can be provided as method, device or computer journey
Sequence product.Therefore, the application can use complete hardware embodiment, complete software implementation or combine software and
The form of the embodiment of hardware aspect.And, the application can use and wherein include calculating one or more
The computer-usable storage medium of machine usable program code (include but not limited to disk memory, CD-ROM,
Optical memory etc.) form of the upper computer program implemented.
The foregoing is only embodiments herein, be not limited to the application.For this area skill
For art personnel, the application can have various modifications and variations.All institutes within spirit herein and principle
Any modification, equivalent substitution and improvement etc. made, within the scope of should be included in claims hereof.