Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Online application of reliability event mode

2025-02-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Recently completed a project using the springboot microservice architecture. It is inevitable to encounter the problem of distributed transactions. The business situation is that users can use points and rebates to pay for orders. In the event of order creation, they need to occupy the points account and rebate account, then consume points, consume rebates, and finally complete the order creation. In the actual development, the points and rebates are other third-party systems, which can not provide us with many interfaces, so the distributed transaction finally adopts the reliability event mode. Data consistency is generally guaranteed.

Local event table

Microservices record business data and events in the same local transaction.

The microservice publishes an event in real time and immediately notifies the associated business service, and updates the recorded event status immediately if the event is published successfully.

The event recovery service periodically recovers unpublished events from the event table, republishes, and updates the recorded event status only after republishing is successful.

Compensation mode

The compensation pattern is a more complex business processing logic that allows businesses with inverse operations to use the pattern.

(the microservice implementation compensation operation is not simply a fallback to the state when the business occurs, because there may be other concurrent requests that change the state at the same time. Reverse operation is generally used to complete the compensation. The compensation mode uses an additional coordination service to coordinate the micro-services that need to ensure consistency, and the coordination service invokes each micro-service sequentially. If a micro-service invocation exception (including business exception and technical exception) cancels all previously successfully invoked micro-services.

TCC model needs coordination service and work service as well as compensation mode, and coordination service can also be implemented as a framework as a general service. Unlike the compensation model, the TCC services framework does not need to record detailed business pipelining, and the business elements that complete confirm and cancel operations are provided by business services.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report