I am using a rest endpoint to start a java process using executeWithLock which takes in a LockingTaskExecutor.TaskWithResult(call method of TaskWithResult calls the java process/method). This works fine and it allows only single execution of java process at any point of time and I can get the status of execution from TaskResult. In some cases the java process is long running and the rest call stalls as the process is still getting executed,
I tried to make my java process @Async but then the lock is released irrespective of the execution of the async process and unlock before completion of async process.
Is there any way to get the lock status by name and so that in case of no lock I can call executeWithLock in a separate thread and return immediately? if it is already locked I will skip calling executeWithLock and return immediately.
or is there any other solution for this kind of scenario?