4

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();
} 
nekperu15739
  • 3,311
  • 2
  • 26
  • 25

2 Answers2

3

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)

nekperu15739
  • 3,311
  • 2
  • 26
  • 25
0

You'd have to provide your own impl of SchedulerProxyScheduledLockAdvisor that verifies the task's class whether it's a TraceRunnable. You can also disable parts of Sleuth if necessary. You can also ask Shedlock's authors for some hooks to fix this.

Marcin Grzejszczak
  • 10,624
  • 1
  • 16
  • 32
  • How do you connect SchedulerProxyScheduledLockAdvisor with SpringLockConfigurationExtractor, since the problem comes in SpringLockConfigurationExtractor.getLockConfiguration? with the instanceof – nekperu15739 Nov 21 '19 at 16:06
  • afair `@Bean SchedulerProxyScheduledLockAdvisor....` is using what you mentioned. So you could create `SchedulerProxyScheduledLockAdvisor` in such a way that it doesn't use the `SpringLockConfigurationExtractor` – Marcin Grzejszczak Nov 21 '19 at 16:16