- Microservices with Clojure
- Anuj Kumar
- 296字
- 2021-06-30 19:24:34
Transactions
Each microservice can use a database of its choice. The chosen databases may or may not have the ACID property (https://en.wikipedia.org/wiki/ACID) and support transactions. This is one of the reasons why distributed transactions are hard to implement with microservices. However, business transactions involving changes across multiple business entities cannot be omitted entirely, and therefore microservices implement distributed transactions by using data workflows, as shown in the following diagram:

Microservices publish events whenever they make a change to the database. The events contain the type of change along with immutable data about the business entities that were affected by this change. Other services then listen to these events asynchronously and perform the changes strictly in the order in which events were published. A single transaction may contain one or more events that may result in cascading events generated by the microservices that are affected by it. Due to the asynchronous nature of the event flow, the consistency achieved across microservices in this case is eventual (https://en.wikipedia.org/wiki/Eventual_consistency).

If a transaction fails, the service that encounters the failure generates compensatory events to nullify the changes made across microservices that have already processed the transaction events in the chain. The compensatory events flow backwards towards the origin of the transaction, as shown in the preceding diagram. Compensatory events are idempotent in nature and retried until they succeed.
- 計算機網(wǎng)絡與通信(第2版)
- EDA技術與VHDL編程
- 物聯(lián)網(wǎng)之魂:物聯(lián)網(wǎng)協(xié)議與物聯(lián)網(wǎng)操作系統(tǒng)
- Hands-On Chatbots and Conversational UI Development
- 網(wǎng)絡創(chuàng)新指數(shù)研究
- 物聯(lián)網(wǎng)概論(第2版)
- 信息通信網(wǎng)絡建設安全管理概要2
- 互聯(lián)網(wǎng)安全的40個智慧洞見:2015年中國互聯(lián)網(wǎng)安全大會文集
- 網(wǎng)絡安全應急響應技術實戰(zhàn)
- Hands-On Bitcoin Programming with Python
- 移動互聯(lián)網(wǎng)環(huán)境下的核心網(wǎng)剖析及演進
- RestKit for iOS
- Cisco無線局域網(wǎng)配置基礎
- 智能物聯(lián)安防視頻技術基礎與應用
- 路由與交換技術