Skip to content

Distributed Lock spring-boot-nebula-distribute-lock ​

Declarative distributed locking built on Redisson.

Add the Dependency ​

xml
<dependency>
    <groupId>io.github.weihubeats</groupId>
    <artifactId>spring-boot-nebula-distribute-lock</artifactId>
    <version>3.0.6</version>
</dependency>

Prerequisite ​

A RedissonClient bean must be configured by yourself (see RedissonConfig in the sample).

Usage ​

java
@NebulaDistributedLock(lockNamePre = "order:updateOrder:", lockNamePost = "#dto.orderId")
public void updateOrder(OrderDTO dto) { ... }
AttributeDefaultDescription
lockNamePre""Lock name prefix
lockNamePost""Lock name suffix, supports SpEL
tryLockfalseWhether to attempt locking
tryWaitTime30Attempt wait time
outTime20Auto-release timeout for the lock
timeUnitSECONDSTime unit
fairLockfalseWhether to use a fair lock

Sample module: spring-boot-nebula-distribute-lock-sample.

Released under the Apache 2.0 License.