Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ShedLock not lock when Sleuth is present

There is an application that run some process by scheduler, like we have multiple instances we choose shedlock to block other run the same process. However, is not working since sleuth provides an instances of Runnable which is TraceRunnable and the expected is ScheduledMethodRunnable. Any ideas to solve this?

class SpringLockConfigurationExtractor

@Override
public Optional<LockConfiguration> getLockConfiguration(Runnable task) {
    if (task instanceof ScheduledMethodRunnable) {
        ScheduledMethodRunnable scheduledMethodRunnable = (ScheduledMethodRunnable) task;
        return getLockConfiguration(scheduledMethodRunnable.getTarget(), scheduledMethodRunnable.getMethod());
    } else {
        logger.debug("Unknown task type " + task);
    }
    return Optional.empty();
} 
like image 938
nekperu15739 Avatar asked Oct 21 '25 12:10

nekperu15739


1 Answers

I talk with developer and follow documentation set the param interceptMode to PROXY_METHOD and its working. He mention that this will be the default value in future releases, in favor of avoid issues like this.

@EnableSchedulerLock(defaultLockAtMostFor = "PT5M", interceptMode = PROXY_METHOD)

like image 148
nekperu15739 Avatar answered Oct 23 '25 09:10

nekperu15739