JD Order-to-weight problem: On the principle of domain driven design in Distributed transaction processing

Source: Internet
Author: User

Original article: http://www.csdn.net/article/2015-01-15/2823577


Order number deduplication problem: Suppose a node sends a new order request to the B node, but the network is likely to fail, it is possible that the distributed transaction has been executed successfully on the B node, but a failed, causing the order request to be re-sent, resulting in duplicate orders

Point: The key issue is the order number of the ID information to prevent duplicate generation, if the ID number can be generated in advance, you can send this ID information each time, so that each processing of the request to idempotent.

Therefore, JD's current program is equivalent to the B node based on commodity information, customer information and so on, made a reverse mapping to the order ID, but this scheme is not flexible, assuming that the customer is to be in 1 seconds in succession to 2 orders???

So, the simpler scenario is to have the browser side generate this order ID number directly: Based on the user ID and item list;

In other words, a simple principle of distributed transaction processing is to ensure idempotent so that the transaction requester generates the transaction ID directly. Note: The order number is not sensitive, so you do not actually need to generate it on the server side. Or, you need an initial virtual order number that prevents "duplicates," and then the server backend can map the build itself, which is fine.

This transaction ID is not actually global, if a sends a transaction request to B, and b needs to send a child transaction request to C during processing, B needs to generate its own child transaction ID

This is actually some idea of domain-driven design in there.

JD Order-to-weight problem: On the principle of domain driven design in Distributed transaction processing

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.