Class JdbcLockRegistry
java.lang.Object
org.springframework.integration.jdbc.lock.JdbcLockRegistry
- All Implemented Interfaces:
- ExpirableLockRegistry,- LockRegistry,- RenewableLockRegistry
public class JdbcLockRegistry
extends Object
implements ExpirableLockRegistry, RenewableLockRegistry
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, Myeonghyeon Lee
- 
Constructor SummaryConstructorsConstructorDescriptionJdbcLockRegistry(LockRepository client) Construct an instance based on the providedLockRepository.
- 
Method SummaryModifier and TypeMethodDescriptionvoidexpireUnusedOlderThan(long age) Remove locks last acquired more than 'age' ago that are not currently locked.Obtains the lock associated with the parameter object.voidRenew the time to live of the lock is associated with the parameter object.voidsetCacheCapacity(int cacheCapacity) Set the capacity of cached locks.voidsetIdleBetweenTries(Duration idleBetweenTries) Specify a @link Duration} to sleep between lock record insert/update attempts.
- 
Constructor Details- 
JdbcLockRegistryConstruct an instance based on the providedLockRepository.- Parameters:
- client- the- LockRepositoryto rely on.
 
 
- 
- 
Method Details- 
setIdleBetweenTriesSpecify a @link Duration} to sleep between lock record insert/update attempts. Defaults to 100 milliseconds.- Parameters:
- idleBetweenTries- the- Durationto sleep between insert/update attempts.
- Since:
- 5.1.8
 
- 
setCacheCapacitypublic void setCacheCapacity(int cacheCapacity) Set the capacity of cached locks.- Parameters:
- cacheCapacity- The capacity of cached lock, (default 100_000).
- Since:
- 5.5.6
 
- 
obtainDescription copied from interface:LockRegistryObtains the lock associated with the parameter object.- Specified by:
- obtainin interface- LockRegistry
- Parameters:
- lockKey- The object with which the lock is associated.
- Returns:
- The associated lock.
 
- 
expireUnusedOlderThanpublic void expireUnusedOlderThan(long age) Description copied from interface:ExpirableLockRegistryRemove locks last acquired more than 'age' ago that are not currently locked.- Specified by:
- expireUnusedOlderThanin interface- ExpirableLockRegistry
- Parameters:
- age- the time since the lock was last obtained.
 
- 
renewLockDescription 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 interface- RenewableLockRegistry
- Parameters:
- lockKey- The object with which the lock is associated.
 
 
-