You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spring-integration-core/src/main/java/org/springframework/integration/support/locks/RenewableLockRegistry.java
+11-1
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright 2020 the original author or authors.
2
+
* Copyright 2020-2024 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
* A {@link LockRegistry} implementing this interface supports the renewal
21
23
* of the time to live of a lock.
22
24
*
23
25
* @author Alexandre Strubel
24
26
* @author Artem Bilan
27
+
* @author NaccOll
25
28
*
26
29
* @since 5.4
27
30
*/
@@ -34,4 +37,11 @@ public interface RenewableLockRegistry extends LockRegistry {
34
37
*/
35
38
voidrenewLock(ObjectlockKey);
36
39
40
+
/**
41
+
* Set the {@link TaskScheduler} to use for the renewal task.
42
+
* when renewalTaskScheduler is set, it will be used to periodically renew the lock to ensure that the lock does not expire while the thread is working.
* An {@link TaskScheduler} to call {@link RenewableLockRegistry#renewLock(Object)} after acquire lock
147
+
*/
148
+
privateTaskSchedulerrenewalTaskScheduler;
149
+
141
150
/**
142
151
* Flag to denote whether the {@link ExecutorService} was provided via the setter and
143
152
* thus should not be shutdown when {@link #destroy()} is called
@@ -207,6 +216,17 @@ public void setExecutor(Executor executor) {
207
216
this.executorExplicitlySet = true;
208
217
}
209
218
219
+
/**
220
+
* Set the {@link TaskScheduler} to use for the renewal task.
221
+
* when renewalTaskScheduler is set, it will be used to periodically renew the lock to ensure that the lock does not expire while the thread is working.
Copy file name to clipboardExpand all lines: spring-integration-redis/src/test/java/org/springframework/integration/redis/util/RedisLockRegistryTests.java
Copy file name to clipboardExpand all lines: src/reference/antora/modules/ROOT/pages/redis.adoc
+3-1
Original file line number
Diff line number
Diff line change
@@ -856,4 +856,6 @@ Default.
856
856
The pub-sub is preferred mode - less network chatter between client Redis server, and more performant - the lock is acquired immediately when subscription is notified about unlocking in the other process.
857
857
However, the Redis does not support pub-sub in the Master/Replica connections (for example in AWS ElastiCache environment), therefore a busy-spin mode is chosen as a default to make the registry working in any environment.
858
858
859
-
Starting with version 6.4, instead of throwing `IllegalStateException`, the `RedisLockRegistry.RedisLock.unlock()` method throws `ConcurrentModificationException` if the ownership of the lock is expired.
859
+
Starting with version 6.4, instead of throwing `IllegalStateException`, the `RedisLockRegistry.RedisLock.unlock()` method throws `ConcurrentModificationException` if the ownership of the lock is expired.
860
+
861
+
Starting with version 6.4, a method `RedisLockRegistry.setRenewalTaskScheduler` is added to configure the scheduler for automatic renewal of locks. When it is set, the lock will be automatically renewed every 1/3 of the expiration time after the lock is successfully acquired, until unlocked or the redis key is removed
Copy file name to clipboardExpand all lines: src/reference/antora/modules/ROOT/pages/whats-new.adoc
+2
Original file line number
Diff line number
Diff line change
@@ -61,6 +61,8 @@ See xref:zeromq.adoc[ZeroMQ Support] for more information.
61
61
Instead of throwing `IllegalStateException`, the `RedisLockRegistry.RedisLock.unlock()` method throws `ConcurrentModificationException` if the ownership of the lock is expired.
62
62
See xref:redis.adoc[Redis Support] for more information.
63
63
64
+
A method `RedisLockRegistry.setRenewalTaskScheduler` is added to configure the scheduler for automatic renewal of locks. When it is set, the lock will be automatically renewed every 1/3 of the expiration time after the lock is successfully acquired, until unlocked or the redis key is removed
0 commit comments