- Building Microservices with .NET Core 2.0(Second Edition)
- Gaurav Aroraa
- 323字
- 2021-07-02 20:13:03
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 in the scope of their respective data stores.
A good example is a user ordering a specific product. At the time the order is being accepted, there is a sufficient quantity available to be ordered. However, by the time the order is logged, the Product service cannot log the orders for some reason. We don't know yet whether is 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 inpidual 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 cause 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—meaning it is impossible to complete it.
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 transactions would result in the reversal of all the previous transactions.
This is 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.
- Computer Vision for the Web
- NLTK基礎(chǔ)教程:用NLTK和Python庫(kù)構(gòu)建機(jī)器學(xué)習(xí)應(yīng)用
- JavaScript動(dòng)態(tài)網(wǎng)頁(yè)開(kāi)發(fā)詳解
- Mastering JBoss Enterprise Application Platform 7
- C++反匯編與逆向分析技術(shù)揭秘(第2版)
- Kotlin開(kāi)發(fā)教程(全2冊(cè))
- 案例式C語(yǔ)言程序設(shè)計(jì)實(shí)驗(yàn)指導(dǎo)
- Regression Analysis with Python
- HTML5+CSS3+JavaScript 從入門(mén)到項(xiàng)目實(shí)踐(超值版)
- Instant GLEW
- HikariCP數(shù)據(jù)庫(kù)連接池實(shí)戰(zhàn)
- Spring MVC Cookbook
- Learning Adobe Muse
- HTML5從入門(mén)到精通(第3版)
- Java程序設(shè)計(jì)項(xiàng)目教程(第二版)