乐观锁定的重试机制(弹簧数据+ JPA) [英] Retry mechanism for optimistic locking (spring data + JPA)
问题描述
我们决定在我们的Web应用程序中使用乐观锁定,以增加并发性并且不使用悲观锁定。
现在我们正在寻找重试解决方案。
我们希望尽可能少地影响我们当前的代码库。
其中一个我们在网络上看到的解决方案是使用带批注的重试拦截器来标记方法为重试。
问题是我们想要注解具有@Transactional的方法他们的注释,但拦截器由于某种原因无法重试。 (拦截器完美地重试非事务性方法)。
所以:
1)重试会对我们的代码产生最小的影响吗?
2)是否有任何有关该解决方案的文档\ tutorials?
3)是否有可能重试@Transactional注释的方法?
干杯!
您有两种方法可以达到此目的:
OR
/ strong>希望这可以帮助你.. !
We decided on using optimistic locking in our web application in order to increase concurrency and without the using of pessimistic locking.
We are now on a lookout for retry solutions.
We would like to have as little impact as possible to our current code base.
One of the solutions we saw on the web is using a retry interceptor with annotation to mark a method as retry able.
Problem is we would like to annotate methods that are having the @Transactional annotation on them but the interceptor fails to retry them for some reason. (the interceptor retries non transactional methods perfectly.)
So:
1) Are there any alternatives for the retry that will have minimum impact on our code?
2) Are there any documentations \ tutorials for that solution?
3) Is it even possible to retry a @Transactional annotated method?
Cheers!
You have two ways to achieve this as follows
Recovering from hibernate optimistic locking exception
OR
Using Spring AOP to Retry Failed Idempotent Concurrent Operations
hope this will help you..!
这篇关于乐观锁定的重试机制(弹簧数据+ JPA)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!