Interface CustomizedSubscriptionLockRepository<D>

Type Parameters:
D - The possibly extended type for JpaSubscriptionLock
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 Details

    • findSampleForPurge

      @Policy(operationTypes=READ) List<D> findSampleForPurge(@Nullable String startingId)
      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

      @Policy(operationTypes=DELETE) boolean clearLock(D lock, boolean force, boolean isRevert)
      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 id
      reservationCount - 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 use SubscriptionLockProperties.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 id
      childIdentifier - The identifier for the child lock. Optional. Will generate an identifier if null.
      Returns:
      The persisted lock entity
    • unlockChild

      @Policy(operationTypes=UPDATE) int unlockChild(String token, boolean propagate)
      Attempt to clear the child lock.
      Parameters:
      token - The token associated with the child lock
      propagate - 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

      @Policy(operationTypes=READ) List<D> getChildLocks(String id)
      Get all child locks for a parent lock
      Parameters:
      id - The parent lock ID
      Returns:
      The list of child locks