当前位置:网站首页>@The problem of cross database query invalidation caused by transactional annotation

@The problem of cross database query invalidation caused by transactional annotation

2022-07-05 03:51:00 Java Punk

Related articles :

@Transactional Failure scenarios for annotations , I've seen too many people fall over this problem , A thorough inquiry , Shut up the interviewer _Java Punk The blog of -CSDN Blog Through the study of this article , You will master the general 【6 Kind of 】@Transactional Failure scenarios , And be able to understand their failure principles , Dig the source code into the grave .https://blog.csdn.net/weixin_44259720/article/details/110181822?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522165655820616782395348213%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=165655820616782395348213&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~rank_v31_ecpm-4-110181822-null-null.nonecase&utm_term=%40Transactional&spm=1018.2226.3001.4450@Transactional Detailed explanation of annotation parameters , And the usage characteristics of annotations ( The collection edition )_Java Punk The blog of -CSDN Blog _transactional Annotation parameters Through this study , You will deepen your understanding of @Transactional Annotation and understanding of all attributes , You can also learn @Transactional Annotate common failure scenarios 【 At the end of the article 】.https://blog.csdn.net/weixin_44259720/article/details/110138972?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522165655820616782395348213%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=165655820616782395348213&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~rank_v31_ecpm-1-110138972-null-null.nonecase&utm_term=%40Transactional&spm=1018.2226.3001.4450 If necessary , Please take away the relevant articles above .


background

Encountered during development , Record the problem .

It is recommended that a service be connected to a database during development , To realize business-oriented micro service configuration , stay RestFull Layer for business integration of services . however , A few days ago, there was a special case , You need to associate multiple databases in a service to complete the query ( Because several databases do not have their own services , No external HSF Interface ).

In this configuration , It is inevitable to query multiple databases in an interface , And need to modify the data .

problem

Due to the addition of @Transactional annotation , The original intention is to realize transaction management , It didn't actually come true , Instead, the database switching failed (master - > slave Failure ), Finally, the data query fails .

terms of settlement

Need to use cross library solutions , Cross database transaction middleware is recommended , Message middle table , Or make use of MQ Achieve best effort notification messages , Achieve the ultimate consistency of data .


原网站

版权声明
本文为[Java Punk]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207050327474990.html