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, Christian Tzolov, Myeonghyeon Lee
-
Constructor Summary
ConstructorDescriptionJdbcLockRegistry
(LockRepository client) Construct an instance based on the providedLockRepository
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
expireUnusedOlderThan
(long age) Remove locks last acquired more than 'age' ago that are not currently locked.Obtain the lock associated with the parameter object.void
Renew the time to live of the lock is associated with the parameter object.void
setCacheCapacity
(int cacheCapacity) Set the capacity of cached locks.void
setIdleBetweenTries
(Duration idleBetweenTries) Specify a @link Duration} to sleep between lock record insert/update attempts.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.integration.support.locks.LockRegistry
executeLocked, executeLocked, executeLocked, executeLocked
-
Constructor Details
-
JdbcLockRegistry
Construct an instance based on the providedLockRepository
.- Parameters:
client
- theLockRepository
to rely on.
-
-
Method Details
-
setIdleBetweenTries
Specify a @link Duration} to sleep between lock record insert/update attempts. Defaults to 100 milliseconds.- Parameters:
idleBetweenTries
- theDuration
to sleep between insert/update attempts.- Since:
- 5.1.8
-
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:LockRegistry
Obtain the lock associated with the parameter object.- Specified by:
obtain
in interfaceLockRegistry
- Parameters:
lockKey
- The object with which the lock is associated.- Returns:
- The associated lock.
-
expireUnusedOlderThan
public void expireUnusedOlderThan(long age) Description copied from interface:ExpirableLockRegistry
Remove locks last acquired more than 'age' ago that are not currently locked.- Specified by:
expireUnusedOlderThan
in interfaceExpirableLockRegistry
- Parameters:
age
- the time since the lock was last obtained.
-
renewLock
Description copied from interface:RenewableLockRegistry
Renew the time to live of the lock is associated with the parameter object. The lock must be held by the current thread- Specified by:
renewLock
in interfaceRenewableLockRegistry
- Parameters:
lockKey
- The object with which the lock is associated.
-