-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Spring Integration 6.x to 7.0 Migration Guide
Spring Integration 7.0
introduces a DistributedLock
abstraction with Time-To-Live API (for now) to let lock objects in the target persistent store to be marked as expired when instances holding the lock is not responsive for some reason, so, any other instance can pick it up.
With this new abstraction the LockRegistry
interface, its extensions and implementations now have a generic argument to dictate what Lock
implementation is provided by that LockRegistry
implementation.
For example, the DefaultLockRegistry
is now like public final class DefaultLockRegistry implements LockRegistry<Lock>
.
Same for public class ZookeeperLockRegistry implements ExpirableLockRegistry<Lock>
.
However, the JdbcLockRegistry
and RedisLockRegistry
are now like:
implements ExpirableLockRegistry<DistributedLock>, RenewableLockRegistry<DistributedLock>
Therefore, their obtain()
method returns now a DistributedLock
instance with the mentioned new lock(Duration ttl)
and tryLock(Duration waitTime, Duration ttl)
contracts.
The RedisLockRegistry
has supported TTL from day one from its default expireAfter
property, but now with lock(Duration ttl)
it can be done per lock usage.
The JdbcLockRegistry
is based on the RDBMS, hence the SQL schemas have been altered for a new EXPIRED_AFTER
column for INT_LOCK
table.
Therefore, for existing DB a DDL like the next one has to be performed to properly migrate the application to Spring Integration 7.0
:
ALTER TABLE INT_LOCK ADD EXPIRED_AFTER TIMESTAMP NOT NULL;