Summary of the invention
The technical problem to be solved by the application is to provide a kind of method for processing business based on idempotent number verification, to the greatest extent
Amount avoids will lead to idempotent number verification failure if there is database delay machine in the prior art and corresponding business processing is lost
The phenomenon that losing.
Present invention also provides a kind of business processing devices based on idempotent number verification, to guarantee the above method in reality
In realization and application.
To solve the above-mentioned problems, this application discloses a kind of method for processing business based on idempotent number verification, this method
Applied to service provider, multiple databases of the service provider are divided into database active and standby each other two-by-two;Include:
In response to the idempotent acquisition request that called side is initiated, idempotent number is generated according to target database determining at random;
The idempotent number is returned into the called side;
In response to the business processing request that called side is initiated, the business processing request includes the idempotent number, to described
Idempotent number is verified;
If verification does not pass through, the called side is notified to re-initiate idempotent acquisition request;
In response to the idempotent acquisition request that called side re-initiates, according to the number active and standby each other with the target database
Idempotent number is generated according to library.
It is optionally, described that the idempotent number is verified, comprising:
The mark of target database is extracted from the idempotent number to determine target database;
According to the data preservation sequence in the target database, the idempotent number sequence is saved to the target data
In library.
Optionally, the target database that the foundation determines at random generates idempotent number, comprising:
The corresponding target database of current business is randomly selected from multiple databases of the service provider;
Obtain the sequence number of current time information and idempotent number;
The mark of the target database, the service code of present type of service, temporal information and set of serial numbers are combined into power
Equal sign.
Optionally, further includes:
If verification passes through, corresponding business is executed according to the present type of service.
This application discloses a kind of business processing device based on idempotent number verification, described device is integrated in service provider
On, multiple databases of the service provider are divided into database active and standby each other two-by-two;Include:
First idempotent generation module, the idempotent acquisition request for initiating in response to called side are determined according to random
Target database generate idempotent number;
Return module, for the idempotent number to be returned to the called side;
Correction verification module, the business processing request for initiating in response to called side, the business processing request includes described
Idempotent number verifies the idempotent number;
Notification module is to verify in unacceptable situation for the result in the correction verification module, notifies the called side
Re-initiate idempotent acquisition request;
Second idempotent generation module, for generating idempotent according to target database database active and standby each other
Number.
Optionally, the correction verification module includes:
Mark module is extracted, for extracting the mark of target database from the idempotent number to determine target data
Library;
Preserving module, for according to the data preservation sequence in the target database, the idempotent number sequence to be saved
To in the target database.
Optionally, the first idempotent generation module includes:
Submodule is determined, for randomly selecting the corresponding mesh of current business from multiple databases of the service provider
Mark database;
Acquisition submodule, for obtaining the sequence number of current time information and idempotent number;
Combine submodule, for by the service code of the mark of the target database, present type of service, temporal information and
Set of serial numbers is combined into idempotent number.
Optionally, further includes:
Business module is executed, is to verify in unacceptable situation for the result in the correction verification module, works as according to described in
Preceding type of service executes corresponding business.
Compared with prior art, the application includes following advantages:
In the embodiment of the present application, the database of service provider storage service data is divided into active and standby each other two-by-two
Database, called side no longer oneself generate idempotent number, but will generate idempotent number when receiving the service request of user's triggering
Request be sent to service provider and generated by service provider and idempotent number and return to called side, called side is based on idempotent number again
Real business processing request is initiated, to trigger verification and follow-up business treatment process of the service provider to idempotent number.
The embodiment of the present application is used, even if the database of service provider database delay machine occurs when carrying out idempotent number verification
In the case where, service provider be also notified that called side re-initiate generate idempotent number request, thus using with delay machine data
Library database active and standby each other regenerates idempotent number and is verified, to ensure that the exploitativeness and height of idempotent number verification
Availability also ensures that business processing can carry out continuously availablely.
Certainly, any product for implementing the application does not necessarily require achieving all the advantages described above at the same time.
Specific embodiment
Below in conjunction with the attached drawing in the embodiment of the present application, technical solutions in the embodiments of the present application carries out clear, complete
Site preparation description, it is clear that described embodiments are only a part of embodiments of the present application, instead of all the embodiments.It is based on
Embodiment in the application, it is obtained by those of ordinary skill in the art without making creative efforts every other
Embodiment shall fall in the protection scope of this application.
The application can be used in numerous general or special purpose computing device environment or configurations.Such as: personal computer, service
Device computer, handheld device or portable device, laptop device, multi-processor device including any of the above devices or devices
Distributed computing environment etc..
The application can describe in the general context of computer-executable instructions executed by a computer, such as program
Module.Generally, program module includes routines performing specific tasks or implementing specific abstract data types, programs, objects, group
Part, data structure etc..The application can also be practiced in a distributed computing environment, in these distributed computing environments, by
Task is executed by the connected remote processing devices of communication network.In a distributed computing environment, program module can be with
In the local and remote computer storage media including storage equipment.
With reference to Fig. 1, a kind of flow chart of the method for processing business embodiment based on idempotent number verification of the application is shown, this
Embodiment may comprise steps of:
Step 101: the idempotent acquisition request initiated in response to called side is generated according to target database determining at random
Idempotent number.
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 example, user is in the cashier system etc. for carrying out Internetbank payment using Third-party payment platform.Called side is receiving user's hair
When the service request risen, such as the currently payment to some order is triggered, then called side first can send out idempotent acquisition request
Service provider is given, without initiating business processing request immediately, can generally carry use in the idempotent acquisition request
Currently initiate the present type of service of business in family.Service provider generally refers to processing system, for example, being responsible for processing cashier system
The background server for the user-pay request that system is sent.Service provider is in the idempotent acquisition request for receiving called side initiation
When, idempotent number is generated with reference to target database determining at random.
Wherein, target database is any one database used in service provider.In the embodiment of the present application, it takes
Multiple databases of business provider are divided into master/slave data library two-by-two, and wherein target database is any one database.With reference to
It is the application scenarios architecture diagram of the application in practical applications shown in Fig. 2.Wherein, called side 201 and service provider
202 by internet connect, service provider connection target database can have it is multiple, as shown in Fig. 2, for example, wherein number
Active and standby each other according to library 01 and 11, database 01 is primary database, and database 11 is corresponding backup database;And 02 He of database
12 is also active and standby each other, and database 02 is primary database, and database 12 is corresponding backup database.Certainly, the content in Fig. 2 is only
Content therein should not be limited the application by an only simple example.
Specifically, how service provider may include: according to some target database generation idempotent number determined at random
Step A1: the corresponding target data of current business is randomly selected from multiple databases of the service provider
Library;
Firstly, service provider randomly selects a database as current business from multiple databases of connection first
Corresponding target database, for example, selection database 01.
Step A2: the sequence number of current time information and idempotent number is obtained;
Service provider obtains current time information from system again, can there is eight, such as 20141103, can also be more
In detail a bit, such as 201411031208.Service provider can also obtain the sequence number of the idempotent number of database generation, the sequence
Row number can generally be obtained by the way of being incremented by, for example, the sequence number of first idempotent number can be 001, and the second idempotent
Number sequence number can be 002.Certainly, database can also be using the sequence number for indicating idempotent number otherwise.
Step A3: by the mark of the target database, the service code of present type of service, temporal information and set of serial numbers
It is combined into idempotent number.
In this step, by the mark of the target database of selection, for example, " 01 ", the service code of present type of service, example
Such as 001 (indicating payment business), and, temporal information and set of serial numbers are combined into unique idempotent number.It in practical applications, can be with
Pre-set the length of idempotent number, such as 18.Wherein, temporal information and sequence number etc. can be according to the length of idempotent number
To adjust oneself length.
Step 102: the idempotent number is returned into the called side.
After service provider generates idempotent number, which is then forwarded to called side.
Step 103: the business processing initiated in response to called side is requested, and business processing request includes the idempotent number, right
The idempotent number is verified, if verification does not pass through, enters step 104.
And called side can just trigger real business processing request after receiving idempotent number, such as provide to service
The real payment request of Fang Faqi will include the idempotent number of service provider return, in business processing request to service
Provider verifies the idempotent number in business processing request.
Wherein, service provider verifies the idempotent number, can specifically include:
Step B1: the mark of target database is extracted from the idempotent number to determine target database;
After service provider gets the idempotent number of called side transmission, target database mark is extracted from idempotent number
Know, such as " 01 ", to determine which database is corresponding target database be.
Step B2: according to the data preservation sequence in the target database, the idempotent number sequence is saved to described
In target database.
Then, idempotent number is sequentially inserted into data by service provider according still further to the data preservation sequence in database 01
In library 01, if service provider can successfully save idempotent number sequence into database 01, illustrate this idempotent school
The result tested is to pass through, that is, the not processed mistake of the corresponding service request of the idempotent number;If preservation is unsuccessful, illustrate this
The result of verification is not pass through, that is, the corresponding service request of the idempotent number has been processed.Wherein, the unique key of database
The uniqueness verification of idempotent number may be implemented in mechanism, to guarantee that same idempotent number will not be saved successfully to the same database
In.
Step 104: if verification does not pass through, the called side being notified to re-initiate idempotent acquisition request.And if
Service provider does not pass through in the verification of step 103, then it is unsuccessful to illustrate that service provider is inserted into idempotent number into database 01,
In this case it is possible as 01 delay machine of database, service provider can notify called side again in this case
Initiate idempotent acquisition request.
Step 105: the idempotent acquisition request re-initiated in response to called side, according to the target database each other
Active and standby database generates idempotent number.
And if called side after receiving the notice of service provider, has re-initiated idempotent acquisition request, clothes
Provider be engaged in after receiving the idempotent acquisition request that called side re-initiates, it is first determined mutual with the target database
It is in the present embodiment the database 11 active and standby each other with database 01, then according to database to be active and standby to client database
11 regenerate idempotent number.Specifically, in this step then service provider can with reference database 11, present type of service,
Current time information and the sequence number of idempotent number etc., reconfiguring generation idempotent number, (concrete mode can refer to step 101
Introduction), and then enter step the circulation of 102 beginning next rounds.
Optionally, in practical applications, after step 103, if verification passes through, can also include:
Step 106: executing corresponding business according to the present type of service.
In this step, if verification passes through, service provider just initiates the current business class of business according to called side
Type executes corresponding business, for example, be carried out operation of withholing if it is payment business.
As it can be seen that in the embodiment of the present application, the database of service provider storage service data is divided into two-by-two each other
Active and standby database, called side no longer oneself generate idempotent number, but will generate when receiving the service request of user's triggering
The request of idempotent number is sent to service provider and generates idempotent number by service provider and return to called side, and called side is based on again
Idempotent number initiates real business processing request, handles to trigger service provider the verification of idempotent number and follow-up business
Process.The embodiment of the present application is used, even if the database of service provider data occurs when carrying out idempotent number verification
In the case where the delay machine of library, service provider is also notified that called side re-initiates the request for generating idempotent number, thus using delay machine
The backup database of database regenerates idempotent number and is verified, to ensure that the exploitativeness and height of idempotent number verification
Availability also ensures that business processing can carry out continuously availablely.
For the aforementioned method embodiment, for simple description, therefore, it is stated as a series of action combinations, still
Those skilled in the art should understand that the application is not limited by the described action sequence, because according to the application, it is certain
Step can be performed in other orders or simultaneously.Secondly, those skilled in the art should also know that, it is described in the specification
Embodiment belong to preferred embodiment, necessary to related actions and modules not necessarily the application.
It is corresponding with method provided by a kind of method for processing business embodiment based on idempotent number verification of above-mentioned the application,
Referring to Fig. 3, present invention also provides a kind of business processing device embodiments based on idempotent number verification, in the present embodiment, should
Device can integrate on service provider, and multiple databases of service provider are divided into database active and standby each other two-by-two;
The apparatus may include:
First idempotent generation module 301, the idempotent acquisition request for being initiated in response to called side, according to random true
Fixed target database generates idempotent number.
Wherein, optionally, the first generation idempotent module 301 may include:
Submodule is determined, for randomly selecting the corresponding mesh of current business from multiple databases of the service provider
Mark database;Acquisition submodule, for obtaining the sequence number of current time information and idempotent number;With combination submodule, for inciting somebody to action
The mark of the 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 the idempotent number to be returned to the called side.
Correction verification module 303, the business processing request for initiating in response to called side, the business processing request includes institute
Idempotent number is stated, the idempotent number is verified.
Wherein, optionally, the correction verification module 303 may include:
Mark module is extracted, for extracting the mark of target database from the idempotent number to determine target data
Library;With preserving module, for according to the data preservation sequence in the target database, the idempotent number sequence to be saved extremely
In the target database.
Notification module 304 is to verify in unacceptable situation for the result in the correction verification module, notifies the calling
Side re-initiates idempotent acquisition request.
Second idempotent generation module 305, for generating power according to target database database active and standby each other
Equal sign.
Optionally, in practical applications, which can also include:
Business module 306 is executed, for working as according to described in the case where the result of the correction verification module is that verification passes through
Preceding type of service executes corresponding business.
As it can be seen that in the present embodiment, the database of service provider storage service data is divided into active and standby each other two-by-two
Database, for called side when receiving the service request of user's triggering, no longer oneself generates idempotent number, but will generate idempotent
Number request be sent to service provider and generated by service provider and idempotent number and return to called side, called side is based on idempotent again
Number the request of real business processing is initiated, so that it is processed to the verification of idempotent number and follow-up business to trigger service provider
Journey.The embodiment of the present application is used, even if the database of service provider database occurs when carrying out idempotent number verification
In the case where delay machine, service provider is also notified that called side re-initiates the request for generating idempotent number, thus using delay machine number
Idempotent number is regenerated according to the backup database in library and is verified, to ensure that the exploitativeness and Gao Ke of idempotent number verification
With property, also ensure that business processing can carry out continuously availablely.
It should be noted that all the embodiments in this specification are described in a progressive manner, each embodiment weight
Point explanation is the difference from other embodiments, and the same or similar parts between the embodiments can be referred to each other.
For device class embodiment, since it is basically similar to the method embodiment, so being described relatively simple, related place ginseng
See the part explanation of embodiment of the method.
Finally, it is to be noted that, herein, relational terms such as first and second and the like be used merely to by
One entity or operation are distinguished with another entity or operation, without necessarily requiring or implying these entities or operation
Between there are any actual relationship or orders.Moreover, the terms "include", "comprise" or its any other variant meaning
Covering non-exclusive inclusion, so that the process, method, article or equipment for including a series of elements not only includes that
A little elements, but also including other elements that are not explicitly listed, or further include for this process, method, article or
The intrinsic element of equipment.In the absence of more restrictions, the element limited by sentence "including a ...", is not arranged
Except there is also other identical elements in the process, method, article or apparatus that includes the element.
The method for processing business provided herein based on idempotent number verification and device are described in detail above,
Specific examples are used herein to illustrate the principle and implementation manner of the present application, and the explanation of above embodiments is only used
The present processes and its core concept are understood in help;At the same time, for those skilled in the art, according to the application's
Thought, there will be changes in the specific implementation manner and application range, in conclusion the content of the present specification should not be construed as
Limitation to the application.