Solution of concurrency Assurance data consistency, idempotent

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.