-
Notifications
You must be signed in to change notification settings - Fork 1.1k
add a LockTemplate
to simplify working with distributed Locks in Spring Integration
#2971
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hey, @joshlong ! I've seen your Spring Tip on the matter: https://spring.io/blog/2019/06/19/spring-tips-distributed-locks-with-spring-integration. I think we rally may accept your suggestion. Meanwhile consider to use existing
It use used in the Framework like this, for example:
Hope that helps a little. However it isn't clear why it brings you some pain since the API is fully based on Java Thank you for the report anyway! |
Fixes spring-projects#2971 * Following best practice and well-known patterns with `Jdbc`, `Rest` or `Jms` templates, introduce `default` methods into `LockRegistry` interface to make it easier to perform tasks when within a lock. * Since all the required logic is now covered by those `LockRegistry.executeLocked()` methods, there is no need in the dedicated abstract `WhileLockedProcessor` class. Deprecated it for removal in the next version * Use a new `LockRegistry.executeLocked()` API in the `FileWritingMessageHandler` instead of just deprecated `WhileLockedProcessor` * To satisfy Java limitations for checked lambdas, introduce `CheckedCallable` and `CheckedRunnable` utilities similar to interfaces in the `io.micrometer.observation.Observation` * Change existing `CheckedFunction` to expose extra generic argument for `Throwable` * Add dedicated chapter for distributed lock into docs * Fix some links and typos in the docs
* GH-2971: Add `LockRegistry.executeLocked()` API Fixes #2971 * Following best practice and well-known patterns with `Jdbc`, `Rest` or `Jms` templates, introduce `default` methods into `LockRegistry` interface to make it easier to perform tasks when within a lock. * Since all the required logic is now covered by those `LockRegistry.executeLocked()` methods, there is no need in the dedicated abstract `WhileLockedProcessor` class. Deprecated it for removal in the next version * Use a new `LockRegistry.executeLocked()` API in the `FileWritingMessageHandler` instead of just deprecated `WhileLockedProcessor` * To satisfy Java limitations for checked lambdas, introduce `CheckedCallable` and `CheckedRunnable` utilities similar to interfaces in the `io.micrometer.observation.Observation` * Change existing `CheckedFunction` to expose extra generic argument for `Throwable` * Add dedicated chapter for distributed lock into docs * Fix some links and typos in the docs * * Fix Javadoc for `CheckedFunction` * Fix language in docs Co-authored-by: Gary Russell <[email protected]> --------- Co-authored-by: Gary Russell <[email protected]>
Please add a
LockTemplate
or something to make using theLockRegistry
easier. It took a lot of attempts before I figured out the right combination of objects was. I've encapsulated it into aLockTemplate
, as shown below, but I'm sure might see use cases I haven't yet addressed here.The text was updated successfully, but these errors were encountered: