Lock Service¶
About Lock¶
Lock service is the function to provide the unique lock in overall intra-mart system.This service is used when you want to disbale the use of particular function or want to serialize the processes.Note
Usage status of Lock can be confirmed from the [System Administrator] - [Application Lock List] Screen.Please refer to System Administrator Operations Guide for detail.
Sample Program¶
After the lock is started, in case process logic is executed and the lock is finally released, the implementation would be as follows.(In this example, the exception will be thrown if the lock cannot be started for 5 seconds.)// Start the Lock NewLock lock = new NewLock("lock_key"); if(!lock.tryLock(5, TimeUnit.SECONDS)) { // Start of lock failed throw new Exception(); } try { // Process logic } finally { // Release lock process lock.unlock(); }
Lock associated with Request¶
If the lock which is associated with the Request is started, please use the method below.NewLock lock = new NewLock("lock_key"); boolean result = lock.tryLockRequestScope(5, TimeUnit.SECONDS);Lock which is started by using this function will be automatically released when the response is returned.It is also possible to release the lock at any timing by using the unlock() function.Please start the lock using this function, if you want to prevent the missed release of lock.Warning
This function provides automatic release by associating the lock with the request. Therefore, it canno be usedinside the asynchronous task or inside the job process executed by the job scheduler.