当前位置: 首页 > news >正文

南京站建设电脑无法登录建设银行网站

南京站建设,电脑无法登录建设银行网站,电子商务网站建设调查问卷,可以直接打开网站的网页mongodb启动不能锁定在我以前的文章中#xff0c;我谈到了对MongoDB批处理程序采用乐观锁定的好处。 如我之前所写#xff0c;乐观锁定异常是可恢复的异常#xff0c;只要我们获取最新的Entity#xff0c;我们就会对其进行更新并保存。 因为我们使用的是MongoDB#xff0… mongodb启动不能锁定 在我以前的文章中我谈到了对MongoDB批处理程序采用乐观锁定的好处。 如我之前所写乐观锁定异常是可恢复的异常只要我们获取最新的Entity我们就会对其进行更新并保存。 因为我们使用的是MongoDB所以我们不必担心本地或XA事务。 在以后的文章中我将演示如何在使用JPA时构建相同的机制。 Spring框架提供了很好的AOP支持因此可以轻松实现自动重试机制这就是我做到的方式。 我们首先定义一个Retry注释 Retention(RetentionPolicy.RUNTIME) Target(ElementType.METHOD) public interface Retry {Class? extends Exception[] on();int times() default 1; } 我们注释了我们的业务逻辑方法例如 Retry(times 10, on org.springframework.dao.OptimisticLockingFailureException.class) public Product updateName(Long id, String name) {Product product productRepository.findOne(id);product.setName(name);LOGGER.info(Updating product {} name to {}, product, name);return productRepository.save(product); } 然后我们只需要AOP方面来拦截业务逻辑调用并在乐观锁定检测的情况下重试。 Aspect public class OptimisticConcurrencyControlAspect {private static final Logger LOGGER LoggerFactory.getLogger(OptimisticConcurrencyControlAspect.class);Around(annotation(vladmihalcea.concurrent.Retry))public Object retry(ProceedingJoinPoint pjp) throws Throwable {Retry retryAnnotation getRetryAnnotation(pjp);return (retryAnnotation ! null) ? proceed(pjp, retryAnnotation) : proceed(pjp);}private Object proceed(ProceedingJoinPoint pjp) throws Throwable {return pjp.proceed();}private Object proceed(ProceedingJoinPoint pjp, Retry retryAnnotation) throws Throwable {int times retryAnnotation.times();Class? extends Throwable[] retryOn retryAnnotation.on();Assert.isTrue(times 0, Retry{times} should be greater than 0!);Assert.isTrue(retryOn.length 0, Retry{on} should have at least one Throwable!);LOGGER.info(Proceed with {} retries on {}, times, Arrays.toString(retryOn));return tryProceeding(pjp, times, retryOn);}private Object tryProceeding(ProceedingJoinPoint pjp, int times, Class? extends Throwable[] retryOn) throws Throwable {try {return proceed(pjp);} catch (Throwable throwable) {if(isRetryThrowable(throwable, retryOn) times-- 0) {LOGGER.info(Optimistic locking detected, {} remaining retries on {}, times, Arrays.toString(retryOn));return tryProceeding(pjp, times, retryOn);}throw throwable;}}private boolean isRetryThrowable(Throwable throwable, Class? extends Throwable[] retryOn) {Throwable[] causes ExceptionUtils.getThrowables(throwable);for(Throwable cause : causes) {for(Class? extends Throwable retryThrowable : retryOn) {if(retryThrowable.isAssignableFrom(cause.getClass())) {return true;}}}return false;}private Retry getRetryAnnotation(ProceedingJoinPoint pjp) throws NoSuchMethodException {MethodSignature signature (MethodSignature) pjp.getSignature();Method method signature.getMethod();Retry retryAnnotation AnnotationUtils.findAnnotation(method, Retry.class);if(retryAnnotation ! null) {return retryAnnotation;}Class[] argClasses new Class[pjp.getArgs().length];for (int i 0; i pjp.getArgs().length; i) {argClasses[i] pjp.getArgs()[i].getClass();}method pjp.getTarget().getClass().getMethod(pjp.getSignature().getName(), argClasses);return AnnotationUtils.findAnnotation(method, Retry.class);} } 该测试开始10个竞标以竞争产品的保存这就是测试日志。 Line 492: INFO [Thread-9]: v.c.a.OptimisticConcurrencyControlAspect - Optimistic locking detected, 9 remaining retries on [class org.springframework.dao.OptimisticLockingFailureException]Line 495: INFO [Thread-3]: v.c.a.OptimisticConcurrencyControlAspect - Optimistic locking detected, 9 remaining retries on [class org.springframework.dao.OptimisticLockingFailureException]Line 504: INFO [Thread-8]: v.c.a.OptimisticConcurrencyControlAspect - Optimistic locking detected, 9 remaining retries on [class org.springframework.dao.OptimisticLockingFailureException]Line 505: INFO [Thread-11]: v.c.a.OptimisticConcurrencyControlAspect - Optimistic locking detected, 9 remaining retries on [class org.springframework.dao.OptimisticLockingFailureException]Line 507: INFO [Thread-10]: v.c.a.OptimisticConcurrencyControlAspect - Optimistic locking detected, 9 remaining retries on [class org.springframework.dao.OptimisticLockingFailureException]Line 513: INFO [Thread-5]: v.c.a.OptimisticConcurrencyControlAspect - Optimistic locking detected, 9 remaining retries on [class org.springframework.dao.OptimisticLockingFailureException]Line 523: INFO [Thread-4]: v.c.a.OptimisticConcurrencyControlAspect - Optimistic locking detected, 9 remaining retries on [class org.springframework.dao.OptimisticLockingFailureException]Line 529: INFO [Thread-3]: v.c.a.OptimisticConcurrencyControlAspect - Optimistic locking detected, 8 remaining retries on [class org.springframework.dao.OptimisticLockingFailureException]Line 586: INFO [Thread-10]: v.c.a.OptimisticConcurrencyControlAspect - Optimistic locking detected, 8 remaining retries on [class org.springframework.dao.OptimisticLockingFailureException]Line 682: INFO [Thread-5]: v.c.a.OptimisticConcurrencyControlAspect - Optimistic locking detected, 8 remaining retries on [class org.springframework.dao.OptimisticLockingFailureException]Line 683: INFO [Thread-3]: v.c.a.OptimisticConcurrencyControlAspect - Optimistic locking detected, 7 remaining retries on [class org.springframework.dao.OptimisticLockingFailureException]Line 686: INFO [Thread-8]: v.c.a.OptimisticConcurrencyControlAspect - Optimistic locking detected, 8 remaining retries on [class org.springframework.dao.OptimisticLockingFailureException]Line 702: INFO [Thread-3]: v.c.a.OptimisticConcurrencyControlAspect - Optimistic locking detected, 6 remaining retries on [class org.springframework.dao.OptimisticLockingFailureException]Line 752: INFO [Thread-5]: v.c.a.OptimisticConcurrencyControlAspect - Optimistic locking detected, 7 remaining retries on [class org.springframework.dao.OptimisticLockingFailureException]Line 756: INFO [Thread-8]: v.c.a.OptimisticConcurrencyControlAspect - Optimistic locking detected, 7 remaining retries on [class org.springframework.dao.OptimisticLockingFailureException]Line 859: INFO [Thread-5]: v.c.a.OptimisticConcurrencyControlAspect - Optimistic locking detected, 6 remaining retries on [class org.springframework.dao.OptimisticLockingFailureException] 代码可在GitHub上获得 。 参考 Vlad Mihalcea博客博客上的JCG合作伙伴 Vlad Mihalcea 对MongoDB进行了乐观锁定重试 。 翻译自: https://www.javacodegeeks.com/2013/11/optimistic-locking-retry-with-mongodb.htmlmongodb启动不能锁定
http://wiki.neutronadmin.com/news/423115/

相关文章:

  • 温州建设信息网站红酒首页网页设计素材
  • 南充建设机械网站江津网站建设口碑
  • 丹阳网站建设价位安徽招标投标信息网
  • 网站建设项目的摘要江门网络建站模板
  • 做区块链的网站网站可以跟博客做互链吗
  • 网站 404 错误页面是否自动跳转免费的国外代理ip
  • 网站项目验收确认书做公司网站协议书模板下载
  • 李贤威wordpress建站教程一个人看的片免费高清大全
  • 如何在网站上做推广温州网站建设前十公司
  • 网站建设都需要什么工具电子商务网站建设课后作业
  • 手机浏览器网站开发工具厚街网站建设费用
  • 做网站用虚拟机还是服务器WordPress添加2233娘
  • 如何接单做网站微信管理中心
  • 郑州网站建设外包热点链接到另一个网站怎么做
  • 网站建设费计入哪个二级科目做家居网站设计
  • 有什么网站可以做深圳初二的试卷练习tp5 商城网站开发
  • 厦门设计师网站黄山网站优化
  • 金坛网站建设公司官方网站旗舰店
  • 企业网站怎么做seo优化四川省建设厅官方网站
  • 网站的备用金怎么做凭证搭建平台 提供舞台
  • 淄博手机网站建设要学好网站开发要会什么
  • 句容做网站wordpress仿安卓主题下载
  • 网站建设的公司上海wordpress 编辑软件
  • photoshop网站视觉设计步骤网站怎么做网上报名
  • 为什么说做网站赚钱中山移动网站设计
  • 网站建设服务器维护内容想找工作去哪个网站
  • 宁波网站建设lonoo湖南免费网站建设
  • 青岛企业做网站磁县专业做网站
  • 谷歌英文网站优化微信手机网页版
  • 网站建设的费用记什么科目网站下载软件入口