Skip to content

CodingZx/cicco-optimistic-lock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

OptimisticLock

基于Spring AOP实现乐观锁重试机制

使用方式

  • 使用@Retry注解

value: 重试次数 默认3次
forException: 针对异常 默认lol.cicco.optimisticlock.exception.OptimisticLockException

    @Retry(value = 5, forException = Exception.class)
    public Object retryMethod() {
        // do something...
    }

例如以下代码:

  @Retry(value = 5, forException = NullPointException.class)
  public Object retryMethod() {
      // do something...
  }

将只针对NullPointException及其子类异常进行重试, 重试次数为5
若方法内部抛出其他类型异常, 将不会重试

示例详见单元测试

About

基于SpringAOP实现乐观锁重试

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages