tag:blogger.com,1999:blog-8369030687505463576.post1313703595160562894..comments2024-02-12T12:29:29.634+02:00Comments on Thinking about IT: Transaction synchronization callbacks in Spring FrameworkAndrei Zagorneanuhttp://www.blogger.com/profile/04979424616588139827noreply@blogger.comBlogger15125tag:blogger.com,1999:blog-8369030687505463576.post-10534064871578585982018-06-20T11:07:29.704+03:002018-06-20T11:07:29.704+03:00Hi Andrei Zagorneanu,
Good article. Thanks for po...Hi Andrei Zagorneanu,<br /><br />Good article. Thanks for posting.<br /><br />I have a situation where lets say I have two services<br />AccountService<br />CustomerService<br />Both annotated with @Transactional with some createXXX() methods.<br />Now from my AccountController lets say I have a method where I would first call createAccount()<br />and once I get back the Account-ID from createAccount() I will then call createCustomer() (To create a Customer and also update Account-ID from Account on the Customer.)<br />But for some reason if createCustomer() fails I will be left with a polluted state where Account has already been persisted but no Customer created.<br />Is TransactionSynchronizationManager relevant here Or should I handle this differently?<br /><br />Thanks,<br />Balathewebhttps://www.blogger.com/profile/16355634124503378759noreply@blogger.comtag:blogger.com,1999:blog-8369030687505463576.post-47178495097422960972018-03-15T19:34:54.569+02:002018-03-15T19:34:54.569+02:00I have a Question!! My @Transactional function cal...I have a Question!! My @Transactional function calls another function whenever there is a rollback... But the problem is that after the function is called and gets executed line by line. The Changes are not getting saved (using .save method) in Database Anonymoushttps://www.blogger.com/profile/11141564936515809601noreply@blogger.comtag:blogger.com,1999:blog-8369030687505463576.post-70592094967809492612015-11-19T00:33:27.830+02:002015-11-19T00:33:27.830+02:00Its a very nice article. Can some one help me in a...Its a very nice article. Can some one help me in acheiving same using CDI transaction managmenet, without springsAnonymoushttps://www.blogger.com/profile/13032661700759290457noreply@blogger.comtag:blogger.com,1999:blog-8369030687505463576.post-63954317335333177722015-10-09T10:26:50.910+03:002015-10-09T10:26:50.910+03:00Thanks! It works perfectlyThanks! It works perfectlyAnonymoushttps://www.blogger.com/profile/04718437138253051854noreply@blogger.comtag:blogger.com,1999:blog-8369030687505463576.post-90914383323050559662015-08-04T11:49:26.666+03:002015-08-04T11:49:26.666+03:00Very helpful article. Thanks very muchVery helpful article. Thanks very muchAnonymoushttps://www.blogger.com/profile/03703375608159240363noreply@blogger.comtag:blogger.com,1999:blog-8369030687505463576.post-89846476104173929892015-05-02T20:09:51.039+03:002015-05-02T20:09:51.039+03:00Very helpful, thanks! I'm using this approach ...Very helpful, thanks! I'm using this approach to publish domain events via string integration.cyrusmithhttps://www.blogger.com/profile/08243677740345603463noreply@blogger.comtag:blogger.com,1999:blog-8369030687505463576.post-71970942435266087612014-11-22T03:12:14.989+02:002014-11-22T03:12:14.989+02:00Nice post.
Is there a way to get more information...Nice post.<br /><br />Is there a way to get more information about the transaction, ie what method was called and the object(s) that were persisted. For example, if a user was created, send an email to that user.bchttps://www.blogger.com/profile/01195812092281697730noreply@blogger.comtag:blogger.com,1999:blog-8369030687505463576.post-62454973680474525902014-03-27T09:34:05.669+02:002014-03-27T09:34:05.669+02:00If your application is a single thread application...If your application is a single thread application then yes, you can replace <i>ThreadLocal></i> with <i>List</i>. But if you are gonna use the AfterCommitExecutor from multiple threads then <i>ThreadLocal</i> allows you to keep the runnables that have to be executed for each thread after a successfull transaction.Andrei Zagorneanuhttps://www.blogger.com/profile/04979424616588139827noreply@blogger.comtag:blogger.com,1999:blog-8369030687505463576.post-63314828992919573442014-03-27T08:17:30.219+02:002014-03-27T08:17:30.219+02:00Excellent trick. Why is ThreadLocal needed here? I...Excellent trick. Why is ThreadLocal needed here? It can be just a List to hold Runnables? Is ThreadLocal required?Anonymoushttps://www.blogger.com/profile/09755994156691076635noreply@blogger.comtag:blogger.com,1999:blog-8369030687505463576.post-67135410470311034272013-12-24T22:15:21.142+02:002013-12-24T22:15:21.142+02:00Check whether you have configured Spring properly ...Check whether you have configured Spring properly in your project. Download the project sources and see org.zmeu.blog.spring.transaction.configuration.SpringConfiguration. There are 2 important things there:<br />1. @EnableTransactionManagement<br />2. PlatformTransactionManager bean defined in the context.Andrei Zagorneanuhttps://www.blogger.com/profile/04979424616588139827noreply@blogger.comtag:blogger.com,1999:blog-8369030687505463576.post-33970830818120667972013-12-24T15:05:58.182+02:002013-12-24T15:05:58.182+02:00I am using @Transactional in my service layer ever...I am using @Transactional in my service layer everthing is working fine by changes are not being reflected in DB.Anonymoushttps://www.blogger.com/profile/07654274697191031493noreply@blogger.comtag:blogger.com,1999:blog-8369030687505463576.post-40821865918181228162013-10-14T09:22:30.497+03:002013-10-14T09:22:30.497+03:00Good!Good!Andrei Zagorneanuhttps://www.blogger.com/profile/04979424616588139827noreply@blogger.comtag:blogger.com,1999:blog-8369030687505463576.post-16766705631283069892013-10-13T21:55:10.799+03:002013-10-13T21:55:10.799+03:00Thank you for pointing me to the important note in...Thank you for pointing me to the important note in the TransactionSynchronization.afterCommit() javadoc. Solved my problem.Barthttps://www.blogger.com/profile/12164851944304257772noreply@blogger.comtag:blogger.com,1999:blog-8369030687505463576.post-12909710535872693592013-07-31T09:35:08.486+03:002013-07-31T09:35:08.486+03:00You are always welcome!You are always welcome!Andrei Zagorneanuhttps://www.blogger.com/profile/04979424616588139827noreply@blogger.comtag:blogger.com,1999:blog-8369030687505463576.post-16615359959968801012013-07-31T09:27:20.759+03:002013-07-31T09:27:20.759+03:00You made my day today. Thank you very much. You do...You made my day today. Thank you very much. You don't know how much time I have wasted to figure out the solution. <br /><br />Thank you very much !Sanjay Kumarhttps://www.blogger.com/profile/15793003232283561785noreply@blogger.com