官术网_书友最值得收藏!

Transaction

With our foreign keys gone and the database split into smaller parts, we need to devise our own mechanisms for handling data integrity. Here, we need to factor in the possibility that not all services would successfully go through a transaction for the scope of their respective data stores.

A good example could be a user ordering a specific product. At the time the order is being accepted, there is sufficient quantity available to be ordered. However, by the time the order is logged, the Product service could not log the orders for some reason. We don't know yet whether this was due to insufficient quantity or some other communication fault within the system. There are two possible options here. Let's discuss them one by one.

The first option is to try again and perform the remaining part of the transaction sometime later. This would require us to orchestrate the whole transaction in a way that tracks individual transactions across services. So every transaction that leads to transactions being performed for more than one service must be tracked. In case one of them does not go through, it deserves a retry. This might work for long-lived operations.

However, for other operations, this could cast a real problem. If the operation is not long-lived and you still decide to retry, the outcome will result in either locking out other transactions or making the transaction wait--impossible to be completed. 

Another option that we can contemplate here is to cancel the entire set of transactions spread across various services. This means that a single failure at any stage of the entire set of transaction would result in the reversal of all the previous transactions.

This will be one area where maximum prudence would be required, and it would be time well invested. A stable outcome is only guaranteed when the transactions are planned out well in any microservice-style architecture application.

主站蜘蛛池模板: 宝丰县| 玉龙| 乌鲁木齐市| 馆陶县| 清涧县| 伊通| 建宁县| 黎城县| 苍山县| 大姚县| 盖州市| 永修县| 长武县| 普兰店市| 龙岩市| 濮阳县| 余庆县| 梓潼县| 越西县| 开封市| 辽源市| 册亨县| 佛冈县| 平舆县| 富顺县| 青田县| 云林县| 万宁市| 凤庆县| 图片| 林州市| 叙永县| 齐齐哈尔市| 鲜城| 博兴县| 双辽市| 安阳县| 陆良县| 汕头市| 平塘县| 年辖:市辖区|