乐观锁定的重试机制(弹簧数据+ JPA) [英] Retry mechanism for optimistic locking (spring data + JPA)

查看:117
本文介绍了乐观锁定的重试机制(弹簧数据+ JPA)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们决定在我们的Web应用程序中使用乐观锁定,以增加并发性并且不使用悲观锁定。



现在我们正在寻找重试解决方案。

我们希望尽可能少地影响我们当前的代码库。



其中一个我们在网络上看到的解决方案是使用带批注的重试拦截器来标记方法为重试。



问题是我们想要注解具有@Transactional的方法他们的注释,但拦截器由于某种原因无法重试。 (拦截器完美地重试非事务性方法)。

所以:

1)重试会对我们的代码产生最小的影响吗?



2)是否有任何有关该解决方案的文档\ tutorials?

3)是否有可能重试@Transactional注释的方法?



干杯!

解决方案

您有两种方法可以达到此目的:



OR

/ strong>



使用Spring AOP重试失败的幂等并发操作



希望这可以帮助你.. !

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆