Summary of the invention
Technical problems to be solved in this application are to provide a kind of method for processing business based on idempotent number verification, avoid in order to try one's best may result in, if there is data base's machine of delaying, the phenomenon that idempotent number verifies unsuccessfully and corresponding Business Processing is failed in prior art.
Present invention also provides a kind of business processing device based on idempotent number verification, in order to ensure said method realization in practice and application.
In order to solve the problems referred to above, this application discloses a kind of method for processing business based on idempotent number verification, the method is applied to service provider, and multiple data bases of described service provider are divided into data base active and standby each other between two;Including:
The idempotent number initiated in response to called side obtains request, generates idempotent number according to the target database determined at random;
Described idempotent number is returned to described called side;
In response to the Business Processing request that called side is initiated, the request of described Business Processing includes described idempotent number, and described idempotent number is verified;
If verification is not passed through, then notify that described called side is again initiated idempotent number and obtained request;
Again the idempotent number initiated in response to called side obtains request, generates idempotent number according to the data base active and standby each other with described target database.
Optionally, described described idempotent number is verified, including:
The mark of target database is extracted to determine target database from described idempotent number;
According to the data preservation order in described target database, described idempotent number order is preserved to described target database.
Optionally, the target database that described foundation is determined at random generates idempotent number, including:
The target database that current business is corresponding is randomly selected from multiple data bases of described service provider;
Obtain the serial number of current time information and idempotent number;
The mark of described target database, the service code of present type of service, temporal information and set of serial numbers are combined into idempotent number.
Optionally, also include:
If verification is passed through, then perform corresponding business according to described present type of service.
This application discloses a kind of business processing device based on idempotent number verification, described device is integrated on service provider, and multiple data bases of described service provider are divided into data base active and standby each other between two;Including:
First idempotent generation module, obtains request for the idempotent number initiated in response to called side, generates idempotent number according to the target database determined at random;
Return module, for described idempotent number is returned to described called side;
Correction verification module, for the Business Processing request initiated in response to called side, the request of described Business Processing includes described idempotent number, and described idempotent number is verified;
Notification module, for when the result of described correction verification module be verification do not pass through, notify that described called side is again initiated idempotent number and obtained request;
Second idempotent generation module, for generating idempotent number according to the data base active and standby each other with described target database.
Optionally, described correction verification module includes:
Extract mark module, be used for the mark extracting target database from described idempotent number to determine target database;
Preserve module, for according to the data preservation order in described target database, described idempotent number order being preserved to described target database.
Optionally, the first idempotent generation module includes:
Determine submodule, for randomly selecting the target database that current business is corresponding from multiple data bases of described service provider;
Obtain submodule, for obtaining the serial number of current time information and idempotent number;
Combination submodule, for being combined into idempotent number by the mark of described target database, the service code of present type of service, temporal information and set of serial numbers.
Optionally, also include:
Perform business module, for when the result of described correction verification module be verification do not pass through, perform corresponding business according to described present type of service.
Compared with prior art, the application includes advantages below:
In the embodiment of the present application, the data base of service provider storage service data is divided into data base active and standby each other between two, called side is when receiving the service request that user triggers, no longer oneself generates idempotent number, but the request generating idempotent number is sent to service provider and is generated idempotent number by service provider and return to called side, called side initiates the request of real Business Processing based on idempotent number again, thus Trigger services provider is to the verification of idempotent number and follow-up business processing procedure.Adopt the embodiment of the present application, even if the data base of service provider when carry out idempotent number verification time occur in that data base delay machine, service provider is also notified that called side initiates to generate the request of idempotent number again, thus adopting the data base active and standby each other with the machine data base that delays regenerate idempotent number and verify, thus ensure that the exploitativeness and high availability that idempotent number verifies, also ensure that Business Processing can carry out continuously availablely.
Certainly, the arbitrary product implementing the application it is not absolutely required to reach all the above advantage simultaneously.
Detailed description of the invention
Below in conjunction with the accompanying drawing in the embodiment of the present application, the technical scheme in the embodiment of the present application is clearly and completely described, it is clear that described embodiment is only some embodiments of the present application, rather than whole embodiments.Based on the embodiment in the application, the every other embodiment that those of ordinary skill in the art obtain under not making creative work premise, broadly fall into the scope of the application protection.
The application can be used in numerous general or special purpose calculation element environment or configuration.Such as: personal computer, server computer, handheld device or portable set, laptop device, multi-processor device, the distributed computing environment including any of the above device or equipment etc..
The application can described in the general context of computer executable instructions, for instance program module.Usually, program module includes performing particular task or realizing the routine of particular abstract data type, program, object, assembly, data structure etc..The application can also be put into practice in a distributed computing environment, in these distributed computing environment, the remote processing devices connected by communication network perform task.In a distributed computing environment, program module may be located in the local and remote computer-readable storage medium including storage device.
With reference to Fig. 1, it is shown that the flow chart of a kind of method for processing business embodiment based on idempotent number verification of the application, the present embodiment may comprise steps of:
Step 101: the idempotent number initiated in response to called side obtains request, generates idempotent number according to the target database determined at random.
The embodiment of the present application is applied to service provider.In the embodiment of the present application, called side generally refers to operation system, for instance, user is in the cashier system etc. using Third-party payment platform to carry out Net silver payment.Called side is when receiving Client-initiated service request, such as trigger the current payment to certain order, then first idempotent acquisition request can be sent to service provider by called side, without initiating Business Processing request immediately, in the acquisition request of this idempotent number, generally can carry user currently initiate the present type of service of business.Service provider generally refers to process system, for instance, it is responsible for processing the background server of the user-pay request that cashier system sends.Service provider is when receiving the idempotent number acquisition request that called side is initiated, with reference to the target database determined at random to generate idempotent number.
Wherein, target database is any one data base that service provider uses.In the embodiment of the present application, multiple data bases of service provider are divided into master/slave data storehouse between two, and wherein target database is any one data base.With reference to shown in Fig. 2, for the application application scenarios Organization Chart in actual applications.Wherein, called side 201 and service provider 202 are connected by the Internet, and the target database that service provider connects can have multiple, as shown in Figure 2, for instance, wherein, data base 01 and 11 is active and standby each other, and data base 01 is MDL, and data base 11 is corresponding backup database;And data base 02 and 12 is also active and standby each other, data base 02 is MDL, and data base 12 is corresponding backup database.Certainly, the content in Fig. 2 is only a simple example, content therein should not limited the application.
Concrete, how service provider generates idempotent number according to certain target database determined at random, it is possible to including:
Step A1: randomly select the target database that current business is corresponding from multiple data bases of described service provider;
First, first service provider randomly selects a data base as target database corresponding to current business from the multiple data bases connected, for instance, select data base 01.
Step A2: obtain the serial number of current time information and idempotent number;
Service provider obtains current time information again from system, it is possible to have eight, for instance 20141103, it is also possible in more detail a bit, for instance 201411031208.Service provider can also obtain the serial number of the idempotent number that data base generates, and this serial number generally can adopt incremental mode to obtain, for instance, the serial number of first idempotent number can be 001, and the serial number of idempotent No. the second can be 002.Certainly, data base can also adopt the serial number representing idempotent number otherwise.
Step A3: the mark of described target database, the service code of present type of service, temporal information and set of serial numbers are combined into idempotent number.
In this step, by the mark of the target database of selection, for instance " 01 ", the service code of present type of service, for instance 001 (expression payment business), and, temporal information and set of serial numbers are combined into unique idempotent number.In actual applications, it is possible to pre-set the length of idempotent number, for instance 18.Wherein, temporal information and serial number etc. can adjust the length of oneself according to the length of idempotent number.
Step 102: described idempotent number is returned to described called side.
This idempotent number is then forwarded to called side after generating idempotent number by service provider.
Step 103: the Business Processing request initiated in response to called side, Business Processing request includes described idempotent number, and described idempotent number is verified, if verification is not passed through, then enters step 104.
And called side is after receiving idempotent number, just can trigger real Business Processing request, such as initiate real payment request to service provider, the idempotent number that service provider returns can be included, in order to the idempotent number in the request of this Business Processing is verified by service provider in this Business Processing is asked.
Wherein, described idempotent number is verified by service provider, specifically may include that
Step B1: extract the mark of target database from described idempotent number to determine target database;
After service provider gets the idempotent number that called side sends, from idempotent number, extract target database mark, for instance " 01 ", in order to determine which data base is corresponding target database be.
Step B2: according to the data preservation order in described target database, described idempotent number order is preserved to described target database.
Then, service provider is according still further to the data preservation order in data base 01, idempotent number is sequentially inserted into data base 01, if idempotent number order can successfully be preserved to data base 01 by service provider, then illustrate that result that this idempotent number verifies is for passing through, that is, the not processed mistake of service request that this idempotent number is corresponding;If preserving unsuccessful, then illustrate that the result of this verification is not for pass through, i.e. the service request that this idempotent number is corresponding is processed.Wherein, the unique key mechanism of data base can realize the uniqueness verification of idempotent number, ensures that same idempotent number will not successfully preserve to same data base.
Step 104: if verification is not passed through, then notify that described called side is again initiated idempotent number and obtained request.And if service provider does not pass through in the verification of step 103, then illustrate that service provider inserts idempotent number in data base 01 unsuccessful, in this case being possible as data base 01 to delay machine, service provider can notify that called side is again initiated idempotent number and obtained request in this case.
Step 105: the idempotent number again initiated in response to called side obtains request, generates idempotent number according to the data base active and standby each other with described target database.
And if called side is after the notice receiving service provider, again initiate idempotent number and obtain request, service provider is after receiving the idempotent number acquisition request that called side is initiated again, first determine active and standby to client database each other with described target database, namely data base 11 active and standby each other with data base 01 in the present embodiment, then regenerates idempotent number according to data base 11.Concrete, then service provider is referred to data base 11 in this step, present type of service, current time information, and the serial number etc. of idempotent number, reconfigure and generate the idempotent number introduction of step 101 (the concrete mode be referred to), and then enter step 102 and start the circulation of next round.
Optionally, in actual applications, after step 103, if verification is passed through, it is also possible to including:
Step 106: perform corresponding business according to described present type of service.
In this step, if verification is passed through, then the present type of service that service provider just initiates business according to called side performs corresponding business, for instance, if payment business is carried out operation of withholing.
Visible, in the embodiment of the present application, the data base of service provider storage service data is divided into data base active and standby each other between two, called side is when receiving the service request that user triggers, no longer oneself generates idempotent number, but the request generating idempotent number is sent to service provider and is generated idempotent number by service provider and return to called side, called side initiates the request of real Business Processing based on idempotent number again, thus Trigger services provider is to the verification of idempotent number and follow-up business processing procedure.Adopt the embodiment of the present application, even if the data base of service provider when carry out idempotent number verification time occur in that data base delay machine, service provider is also notified that called side initiates to generate the request of idempotent number again, thus adopting the backup database of the machine data base that delays regenerate idempotent number and verify, thus ensure that the exploitativeness and high availability that idempotent number verifies, also ensure that Business Processing can carry out continuously availablely.
For aforesaid embodiment of the method, in order to be briefly described, therefore it is all expressed as a series of combination of actions, but those skilled in the art should know, the application is not by the restriction of described sequence of movement, because according to the application, some step can adopt other orders or carry out simultaneously.Secondly, those skilled in the art also should know, embodiment described in this description belongs to preferred embodiment, necessary to involved action and module not necessarily the application.
The method that the method for processing business embodiment that based on idempotent number verify a kind of with above-mentioned the application provides is corresponding, referring to Fig. 3, present invention also provides a kind of business processing device embodiment based on idempotent number verification, in the present embodiment, this device can be integrated on service provider, and multiple data bases of service provider are divided into data base active and standby each other between two;This device may include that
First idempotent generation module 301, obtains request for the idempotent number initiated in response to called side, generates idempotent number according to the target database determined at random.
Wherein, optionally, the first generation idempotent module 301 may include that
Determine submodule, for randomly selecting the target database that current business is corresponding from multiple data bases of described service provider;Obtain submodule, for obtaining the serial number of current time information and idempotent number;With, combine submodule, for the mark of described target database, the service code of present type of service, temporal information and set of serial numbers are combined into idempotent number.
Return module 302, for described idempotent number is returned to described called side.
Correction verification module 303, for the Business Processing request initiated in response to called side, the request of described Business Processing includes described idempotent number, and described idempotent number is verified.
Wherein, optionally, described correction verification module 303 may include that
Extract mark module, be used for the mark extracting target database from described idempotent number to determine target database;With, preserve module, for according to the data preservation order in described target database, described idempotent number order being preserved to described target database.
Notification module 304, for when the result of described correction verification module be verification do not pass through, notify that described called side is again initiated idempotent number and obtained request.
Second idempotent generation module 305, for generating idempotent number according to the data base active and standby each other with described target database.
Optionally, in actual applications, this device can also include:
Perform business module 306, for when the result of described correction verification module be verify by, perform corresponding business according to described present type of service.
Visible, in the present embodiment, the data base of service provider storage service data is divided into data base active and standby each other between two, called side is when receiving the service request that user triggers, no longer oneself generates idempotent number, but the request generating idempotent number is sent to service provider and is generated idempotent number return to called side by service provider, called side initiates real Business Processing request based on idempotent number again, thus Trigger services provider is to the verification of idempotent number and follow-up business processing procedure.Adopt the embodiment of the present application, even if the data base of service provider when carry out idempotent number verification time occur in that data base delay machine, service provider is also notified that called side initiates to generate the request of idempotent number again, thus adopting the backup database of the machine data base that delays regenerate idempotent number and verify, thus ensure that the exploitativeness and high availability that idempotent number verifies, also ensure that Business Processing can carry out continuously availablely.
It should be noted that each embodiment in this specification all adopts the mode gone forward one by one to describe, what each embodiment stressed is the difference with other embodiments, between each embodiment identical similar part mutually referring to.For device class embodiment, due to itself and embodiment of the method basic simlarity, so what describe is fairly simple, relevant part illustrates referring to the part of embodiment of the method.
Finally, it can further be stated that, in this article, the relational terms of such as first and second or the like is used merely to separate an entity or operation with another entity or operating space, and not necessarily requires or imply the relation that there is any this reality between these entities or operation or sequentially.And, term " includes ", " comprising " or its any other variant are intended to comprising of nonexcludability, so that include the process of a series of key element, method, article or equipment not only include those key elements, but also include other key elements being not expressly set out, or also include the key element intrinsic for this process, method, article or equipment.When there is no more restriction, statement " including ... " key element limited, it is not excluded that there is also other identical element in including the process of described key element, method, article or equipment.
Above the method for processing business based on idempotent number verification provided herein and device are described in detail, principle and the embodiment of the application are set forth by specific case used herein, and the explanation of above example is only intended to help and understands the present processes and core concept thereof;Simultaneously for one of ordinary skill in the art, according to the thought of the application, all will change in specific embodiments and applications, in sum, this specification content should not be construed as the restriction to the application.