lukas-krecan / ShedLock

Distributed lock for your scheduled tasks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Option to throw exception if task not executed

hadimansuri opened this issue · comments

Is your feature request related to a problem? Please describe.
Currently if it fails to acquire lock, the task is ignored.

Add a configuration option to throw exception.

Describe the solution you'd like

  @SchedulerLock(name = "my-job", throwException=true)
  public void job() {

  }

In case it fails to acquire lock throw an exception like CouldNotAcquireLockException ,...

Describe alternatives you've considered
Introduce a new @DistributedLock annotation

Current workaround: Make return type of the method Optional, in case task is not executed, the result will be an empty optional. the caller should throw an exception

Additional context
Distributed lock for long running operations triggered by users

You can implement it using this