Class JdbcLockRegistry
java.lang.Object
org.springframework.integration.jdbc.lock.JdbcLockRegistry
- All Implemented Interfaces:
ExpirableLockRegistry<DistributedLock>,LockRegistry<DistributedLock>,RenewableLockRegistry<DistributedLock>
public class JdbcLockRegistry
extends Object
implements ExpirableLockRegistry<DistributedLock>, RenewableLockRegistry<DistributedLock>
An
ExpirableLockRegistry using a shared database to co-ordinate the locks.
Provides the same semantics as the
DefaultLockRegistry, but the
locks taken will be global, as long as the underlying database supports the
"serializable" isolation level in its transactions.- Since:
- 4.3
- Author:
- Dave Syer, Artem Bilan, Vedran Pavic, Kai Zimmermann, Bartosz Rempuszewski, Gary Russell, Alexandre Strubel, Stefan Vassilev, Olivier Hubaut, Fran Aranda, Unseok Kim, Christian Tzolov, Myeonghyeon Lee, Eddie Cho
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DurationDefault value for the time-to-live property. -
Constructor Summary
ConstructorsConstructorDescriptionJdbcLockRegistry(LockRepository client) Construct an instance based on the providedLockRepository.JdbcLockRegistry(LockRepository client, Duration expireAfter) Create a lock registry with the supplied lock expiration. -
Method Summary
Modifier and TypeMethodDescriptionvoidexpireUnusedOlderThan(long age) Remove locks last acquired more than 'age' ago that are not currently locked.Obtain the lock associated with the parameter object.protected StringvoidRenew the time to live of the lock is associated with the parameter object.voidRenew the time to live of the lock is associated with the parameter object with a specific value.voidsetCacheCapacity(int cacheCapacity) Set the capacity of cached locks.voidsetIdleBetweenTries(Duration idleBetweenTries) Specify aDurationto sleep between lock record insert/update attempts.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.integration.support.locks.LockRegistry
executeLocked, executeLocked, executeLocked, executeLockedMethods inherited from interface org.springframework.integration.support.locks.RenewableLockRegistry
setRenewalTaskScheduler
-
Field Details
-
DEFAULT_TTL
-
-
Constructor Details
-
JdbcLockRegistry
Construct an instance based on the providedLockRepository.- Parameters:
client- theLockRepositoryto rely on.
-
JdbcLockRegistry
Create a lock registry with the supplied lock expiration.- Parameters:
client- theLockRepositoryto rely on.expireAfter- The expiration inDuration.- Since:
- 7.0
-
-
Method Details
-
setIdleBetweenTries
-
setCacheCapacity
public void setCacheCapacity(int cacheCapacity) Set the capacity of cached locks.- Parameters:
cacheCapacity- The capacity of cached lock, (default 100_000).- Since:
- 5.5.6
-
obtain
Description copied from interface:LockRegistryObtain the lock associated with the parameter object.- Specified by:
obtainin interfaceLockRegistry<DistributedLock>- Parameters:
lockKey- The object with which the lock is associated.- Returns:
- The associated lock.
-
pathFor
-
expireUnusedOlderThan
public void expireUnusedOlderThan(long age) Description copied from interface:ExpirableLockRegistryRemove locks last acquired more than 'age' ago that are not currently locked.- Specified by:
expireUnusedOlderThanin interfaceExpirableLockRegistry<DistributedLock>- Parameters:
age- the time since the lock was last obtained.
-
renewLock
Description copied from interface:RenewableLockRegistryRenew the time to live of the lock is associated with the parameter object. The lock must be held by the current thread- Specified by:
renewLockin interfaceRenewableLockRegistry<DistributedLock>- Parameters:
lockKey- The object with which the lock is associated.
-
renewLock
Description copied from interface:RenewableLockRegistryRenew the time to live of the lock is associated with the parameter object with a specific value. The lock must be held by the current thread- Specified by:
renewLockin interfaceRenewableLockRegistry<DistributedLock>- Parameters:
lockKey- The object with which the lock is associated.customTtl- the specific time-to-live for the lock status data
-