Solutions for high concurrency, guaranteed data consistency, idempotent
basic idea: before each request service, you must first invoke the token service, get a unique token, and then take the token ID parameter to invoke the related service. Because this token ID is unique, this can effectively prevent the same business from executing multiple times.
The steps are as follows:
Step1. First create a table Open_ticket in the database that holds the token-related information;
Step2. Define parameters for invoking the token service: At a minimum, the operation user, the business number, the business scenario type;
Step3. Defining a service that gets a token ticketdto builderticket (Ticketcreateparam ticketcreateparam)
A. Check the integrity of the creation parameters;
B. Check that the current unique business number token has been created;
C.ticketdto Newticket = Builder (ticketcreateparam);
Step4. The status of the update token information is successful after the call to the related business service execution succeeds.
Description: Generally in the e-commerce project, this high concurrency is very common, in order to prevent the same business is repeatedly executed, such as an order may be multiple payments, repeated deduction of money, we can be effectively avoided through this scheme, such as when the same order to pay the second time, because the order number and the last time the same, The business type is also the order payment, so when the "token service" is invoked, it is checked that the business has already created the token ID, and the status is accepted, at this point, the creation of the token service information will fail, directly return, the subsequent payment operation will not be executed to the
This article is from the "flyfish" blog, make sure to keep this source http://9381188.blog.51cto.com/9371188/1793287
Solution of concurrency Assurance data consistency, idempotent