In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains the "thread pool runtime found that the job method transactions do not take effect how to solve", the article explained the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "thread pool runtime found job method transactions do not take effect how to solve" it!
Problem description:
The thread pool is used to run the instance method of the same class in the project. The code is roughly as follows. The runtime finds that the transaction of the job method does not take effect.
@ Transactional public void doJob () {EXECOTOR.execute (()-> job ());} @ Transactional public void job () {/ / db operation}
Cause analysis:
When debug enters the job method, it is found that the instance running the job method is a normal instance rather than a proxy object, so aop enhancement cannot be implemented.
Solution:
Call AopContext.currentProxy () in doJob to get the current proxy object, and call the job method on the proxy object
Transactional public void doJob () {AAAService proxy = (AAAService) AopContext.currentProxy (); EXECOTOR.execute (()-> proxy.job ());} @ Transactional public void job () {/ / db operation}
Thank you for your reading, the above is the "thread pool runtime found that the transaction of the job method does not take effect how to solve the content", after the study of this article, I believe you on the thread pool runtime found that the transaction of the job method does not take effect how to solve this problem has a more profound experience, the specific use of the need for everyone to practice and verify. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.