- 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.
- 廣電5G從入門到精通
- Modern JavaScript Web Development Cookbook
- 解析QUIC/HTTP3:未來互聯網的基石
- 工業控制網絡安全技術與實踐
- TCP/IP入門經典(第5版)
- 物聯網+BIM:構建數字孿生的未來
- Mastering TypeScript 3
- OMNeT++與網絡仿真
- Windows Server 2012 Hyper-V虛擬化管理實踐
- 網絡安全應急響應技術實戰指南
- 4G小基站系統原理、組網及應用
- 5G時代的大數據技術架構和關鍵技術詳解
- bash網絡安全運維
- Enterprise ApplicationDevelopment with Ext JSand Spring
- 想象的互動:網絡人際傳播中的印象形成