当前位置:网站首页>@Transactional 注解导致跨库查询失效的问题
@Transactional 注解导致跨库查询失效的问题
2022-07-05 03:35:00 【Java Punk】
相关文章:
@Transactional 注解的失效场景,这个问题见过太多的人栽跟头,一篇刨根问底,让面试官都闭嘴_Java Punk的博客-CSDN博客通过本篇的学习,你将掌握大概【6种】@Transactional 的失效场景,并且能够明白各自的失效原理,把源码刨到祖坟上。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 注解参数详解,以及注解的使用特性说明(典藏版)_Java Punk的博客-CSDN博客_transactional注解参数通过本篇学习,你将加深对@Transactional 注解以及所有的属性的理解,还可以学习到@Transactional 注解常见的失效场景【文章最后】。
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如果有需要,上面的相关文章请拿走不谢。
背景
开发中遇到的,记录一下问题。
建议在开发中一个服务连接一个数据库,来实现业务型的微服务配置,在RestFull层进行服务的业务融合。但是,前几天出现了一个特例,需要在一个服务中关联多个数据库来完成查询(因为好几个数据库本身还没有自己的服务,没有对外HSF接口)。
在这样的配置下,难免出现一个接口中查询多库,并且需要修改数据的情况。
问题
由于在接口上增加了@Transactional 注解,本意是希望实现事务管理,实际上并没有实现,反而造成了数据库切换时候失败了(master - > slave 失败),最终导致数据查询失败。

解决办法
需要使用跨库解决方案,建议跨库事务中间件,消息中间表,或者利用MQ实现最大努力通知消息,实现数据的最终一致性。

边栏推荐
- Clickhouse同步mysql(基于物化引擎)
- Kuboard
- How can we truncate the float64 type to a specific precision- How can we truncate float64 type to a particular precision?
- [luat-air105] 4.1 file system FS
- 问下,这个ADB mysql支持sqlserver吗?
- 有個疑問 flink sql cdc 的話可以設置並行度麼, 並行度大於1會有順序問題吧?
- Logstash、Fluentd、Fluent Bit、Vector? How to choose the appropriate open source log collector
- Difference between MotionEvent. getRawX and MotionEvent. getX
- De debugging (set the main thread as hidden debugging to destroy the debugging Channel & debugger detection)
- The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
猜你喜欢

程序员的视力怎么样? | 每日趣闻

SQL injection exercise -- sqli Labs

Thread Basics

Talk about the SQL server version of DTM sub transaction barrier function

Accuracy problem and solution of BigDecimal
![[web Audit - source code disclosure] obtain source code methods and use tools](/img/ea/84e67a1fca0e12cc4452c744c242b4.png)
[web Audit - source code disclosure] obtain source code methods and use tools
![[groovy] groovy environment setup (download groovy | install groovy | configure groovy environment variables)](/img/99/bb05b6c48a9e70ca7ff77733d954b9.jpg)
[groovy] groovy environment setup (download groovy | install groovy | configure groovy environment variables)
![[untitled]](/img/53/f67c53d4ada382ec42f97cf68d9c71.jpg)
[untitled]
![[C language] address book - dynamic and static implementation](/img/eb/07e7a32a172e5ae41457cf8a49c130.jpg)
[C language] address book - dynamic and static implementation

Logstash、Fluentd、Fluent Bit、Vector? How to choose the appropriate open source log collector
随机推荐
Zero foundation uses paddlepaddle to build lenet-5 network
El tree whether leaf node or not, the drop-down button is permanent
[positioning in JS]
In MySQL Association query, the foreign key is null. What if the data cannot be found?
Thread Basics
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
汇编-入门
Subversive cognition: what does SRE do?
New interesting test applet source code_ Test available
040. (2.9) relieved
Kbp206-asemi rectifier bridge kbp206
【web審計-源碼泄露】獲取源碼方法,利用工具
SQL injection exercise -- sqli Labs
Multimedia query
[groovy] loop control (number injection function implements loop | times function | upto function | downto function | step function | closure can be written outside as the final parameter)
Kubernetes - identity and authority authentication
Mongodb common commands
Share the newly released web application development framework based on blazor Technology
Une question est de savoir si Flink SQL CDC peut définir le parallélisme. Si le parallélisme est supérieur à 1, il y aura un problème d'ordre?
Pat class a 1160 forever (class B 1104 forever)