Interface ResourceLockProvider
- All Known Implementing Classes:
ExternalResourceLockProvider
public interface ResourceLockProvider
Provides the ability to lock and unlock resources.
- Author:
- Jacob Mitash
-
Method Summary
Modifier and TypeMethodDescriptionvoidfinishLock(String lockToken, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Update the status of the lock to indicate the associated process is complete.obtainLock(String contextId, String conceptKey, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Obtains a permanent resource lock, typically used for idempotency messages.default StringobtainTemporalLock(String contextId, String conceptKey, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Obtains a temporal resource lock.obtainTemporalLock(String contextId, String conceptKey, Duration lockTtl, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Obtains a temporal resource lock.voidreleaseLock(String token, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Releases a resource lock using a token.
-
Method Details
-
obtainLock
String obtainLock(String contextId, String conceptKey, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Obtains a permanent resource lock, typically used for idempotency messages.- Parameters:
contextId- the context ID of the entity to lockconceptKey- some key indicating what is being locked or by whocontextInfo- the context of the request- Returns:
- a token that can be used to release the lock
-
obtainTemporalLock
default String obtainTemporalLock(String contextId, String conceptKey, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Obtains a temporal resource lock. This lock is automatically released after a very short duration. By default, the duration is 10 seconds and can be changed via the "broadleaf.order.web.order-lock-ttl" configuration property.- Parameters:
contextId- the context ID of the entity to lockconceptKey- some key indicating what is being locked or by whocontextInfo- the context of the request- Returns:
- a token that can be used to release the lock
- Since:
- Order Operations Service 3.0.0, Release Train 3.0.0
-
obtainTemporalLock
String obtainTemporalLock(String contextId, String conceptKey, @Nullable Duration lockTtl, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Obtains a temporal resource lock. This lock is automatically released afterlockTtlif specified. By default, if thelockTtlis null, the duration configured via the "broadleaf.order.web.order-lock-ttl" property will be used.- Parameters:
contextId- the context ID of the entity to lockconceptKey- some key indicating what is being locked or by wholockTtl- amount of time that an order lock is held, before it expirescontextInfo- the context of the request- Returns:
- a token that can be used to release the lock
- Since:
- Order Operations Service 3.0.0, Release Train 3.0.0
-
releaseLock
void releaseLock(String token, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Releases a resource lock using a token. The token should be obtained viaobtainLock(String, String, ContextInfo).- Parameters:
token- the token tied to the lock which should be releasedcontextInfo- the context of the request
-
finishLock
void finishLock(String lockToken, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Update the status of the lock to indicate the associated process is complete.- Parameters:
lockToken- The unique token that was provided when the lock was obtainedcontextInfo- the context of the request
-