Interface CustomizedSubscriptionLockRepository<D>
- Type Parameters:
D- The possibly extended type forJpaSubscriptionLock
- All Known Subinterfaces:
JpaSubscriptionLockRepository<D>,SubscriptionLockRepository<D>
- All Known Implementing Classes:
JpaCustomizedSubscriptionLockRepository
public interface CustomizedSubscriptionLockRepository<D>
This repository is used to manage locks on subscriptions. The locks are used to prevent multiple
user interactions from modifying the same subscription at the same time.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanClear the lock.createChildLock(String subscriptionId, String childIdentifier) Attempt to create a child lock on the subscription.createLock(String subscriptionId, Integer reservationCount, List<String> reservationList, Duration expiryDuration) Attempt to create a top-level lock on the subscription.findSampleForPurge(String startingId) Find a sample of locks that are ready to be purged (max size is 100).getChildLocks(String id) Get all child locks for a parent lockintunlockChild(String token, boolean propagate) Attempt to clear the child lock.
-
Method Details
-
findSampleForPurge
Find a sample of locks that are ready to be purged (max size is 100). Purging is used to remove orphaned locks that were not properly deleted as part of the normal lock lifecycle.- Parameters:
startingId- The starting id to use for the query. If null, the query will start with the earliest id.- Returns:
- The list of candidate locks to purge.
-
clearLock
Clear the lock. This is used to remove the lock from the system (including any child locks).- Parameters:
lock- The top-level lock to clear.force- Whether to force the lock to be cleared, even if it is not expired.isRevert- Whether the lock is being cleared as part of a revert operation.- Returns:
- true if the lock was successfully cleared, false otherwise.
-
createLock
@Policy(operationTypes=CREATE) List<D> createLock(String subscriptionId, @Nullable Integer reservationCount, @Nullable List<String> reservationList, @Nullable Duration expiryDuration) Attempt to create a top-level lock on the subscription.- Parameters:
subscriptionId- The subscription idreservationCount- The number of child locks to reserve. Optional.reservationList- The list of child lock identifiers to reserve. Optional. If provided, will be favored over reservationCount.expiryDuration- The duration of the lock. Optional. Default is to useSubscriptionLockProperties.getSubscriptionLockExpiration().- Returns:
- The persisted lock entity, and any optional child locks reserved.
- Throws:
LockFailException- notify caller that the lock failed
-
createChildLock
@Policy(operationTypes=CREATE) D createChildLock(String subscriptionId, @Nullable String childIdentifier) Attempt to create a child lock on the subscription.- Parameters:
subscriptionId- The subscription idchildIdentifier- The identifier for the child lock. Optional. Will generate an identifier if null.- Returns:
- The persisted lock entity
-
unlockChild
Attempt to clear the child lock.- Parameters:
token- The token associated with the child lockpropagate- Whether to propagate the token unlock to the parent lock- Returns:
- The number of child locks remaining
- Throws:
UnlockFailException- notify caller that unlock failed
-
getChildLocks
Get all child locks for a parent lock- Parameters:
id- The parent lock ID- Returns:
- The list of child locks
-