pub.storage:lock
WmPublic. Locks an entry and/or data store on behalf of the thread invoking this service.
Important:
When you lock an entry or data store using this service, you must release the lock by using a put (
pub.storage:put) or an explicit unlock (
pub.storage:unlock). If you do not release the lock, other threads will not be able to access the resource until
Integration Server automatically releases the lock after the amount of time specified on the watt.server.storage.lock.maxDuration parameter has passed.
Important:
Be careful when releasing locks with the pub.storage:unlock service. If you release a lock on a data store, another thread can obtain a lock on the data store and delete it, and the entries it contains, even if your thread still has locks on one or more of the entries.
Input Parameters
storeName | String Name of the data store containing the entry. |
key | String Optional. Key of the entry that you want to lock. If key is not supplied and you request: A shared lock, the service obtains a shared lock on the data store, allowing other threads to read and modify entries, but not to delete them. An exclusive lock, the service obtains an exclusive lock on the data store, preventing other threads from locking the data store and the entries, thereby preventing those threads from reading, modifying, or deleting the entries or the data store. If both storeName and key are specified and you request: A shared lock, the service obtains a shared lock on the data store and the entry. An exclusive lock, the service obtains a shared lock on the data store and an exclusive lock on the entry. |
waitLength | String Optional. Length of time, in milliseconds, that you want to wait for this entry to become available if it is already locked by another thread. The default is the default Maximum Lock Wait value, which is specified on the watt.server.storage.lock.maxWait property. You can update this property by using the Settings > Extended page on the Integration Server Administrator. |
lockMode | String Optional. Type of lock you want to place on the entry or data store. Set to: Exclusive to prevent other threads from obtaining a lock on the data store or entry. An exclusive lock on an entry allows you to modify the entry, and prevents other threads from reading or modifying the entry. An exclusive lock on a data store also locks the entries in the data store. In addition, an exclusive lock on a data store allows you to delete the data store. Read is obsolete. If this value is specified, the service obtains a shared lock. Share to prevent other threads from obtaining an exclusive lock on an entry or a data store. A shared lock on an entry allows you to read, but not modify, the entry. A shared lock on a data store prevents another thread from deleting the data store. This is the default. |
Output Parameters
None.
Usage Notes
If you have not specified a
key, and your flow service does not invoke
pub.storage:put or
pub.storage:unlock, or your service throws an exception before invoking
pub.storage:put or
pub.storage:unlock, the entire data store remains locked until the amount of time specified on the watt.server.storage.lock.maxDuration parameter has passed.
If the key does not exist in the data store at the time your flow service executes, the pub.storage:lock service is a NOP (no operation). Set the watt.server.storage.addKeyToStoreIfNotPresent parameter to true if you want the pub.storage:lock service to add the specified key to the data store if the key does not exist at the time the service executes. When the watt.server.storage.addKeyToStoreIfNotPresent parameter is set to true, the pub.storage:lock service creates the specified key, assigns it a NULL value, and then locks the entry in the data store.
If you request an exclusive lock on an entry, the service obtains an exclusive lock on the entry and a shared lock on the data store. If this service finds a shared lock from the same thread on the entry, the service will automatically promote the shared lock on the entry to an exclusive lock.
If you request a shared lock on an entry, the service obtains a shared lock on the entry and a shared lock on the data store.
If you request a shared lock on an entry or a data store and this service finds an exclusive lock from the same thread, the existing exclusive lock will be reused. The exclusive lock will not be demoted to a shared lock.
If you request an exclusive lock on a data store, and this service finds a shared lock from the same thread on the data store, the service will automatically promote the shared lock on the data store to an exclusive lock.