Lock Service¶
Meaning of Lock¶
Lock service is a functionality that does the unique locking for the entire intra-mart system.It is used for disabling the specific functionality or when serialization of processes is to be done.Note
Lock usage status can be checked by [System administrator] – [Application lock list] screen.For details, refer ‘System Administrator Operation Guide’.
Sample Program¶
Execute the process logic after locking. Implement the following to release the lock.(In this sample throw an exception when it is not locked within 5 seconds.)// When locked NewLock lock = new NewLock("lock_key"); if(!lock.tryLock(5, TimeUnit.SECONDS)) { // When lock fails throw new Exception(); } try { // process logic } finally { // When unlocked lock.unlock(); }
Lock Linked With Request¶
Use the following methods to lock which is linked with the request.NewLock lock = new NewLock("lock_key"); boolean result = lock.tryLockRequestScope(5, TimeUnit.SECONDS);The lock using this function gets auto-released when returning the response.Moreover, by using unlock () function, the lock can be released any time.Lock it by using this function to avoid leaks in releasing the lock.Warning
This function cannot be used in asynchronous tasks or in the processing of job executed by jobscheduler,since lock is linked with the request and it is auto released.