我有这样的代码:
private final ThreadPoolTaskScheduler threadPoolTaskScheduler; // spring
private final LockingTaskExecutor lockingTaskExecutor; // shedlock
....
threadPoolTaskScheduler.scheduleWithFixedDelay(
() -> {
lockConfiguration = ...
long start = System.currentTimeMillis();
LOGGER.info("Spring scheduler started task, awaiting shedlock ");
lockingTaskExecutor.executeWithLock((Runnable) () -> {
LOGGER.info("Shedlock acquired. duration=[{}]ms", propertyItem, System.currentTimeMillis() - start);
taks();
},
lockConfiguration);
}, someInterval);
我有 2 个节点。根据日志,我看到task()
仅在第一个节点上有效的情况。在第二个节点上我只看到Spring scheduler started task, awaiting shedlock
我认为它不应该以这种方式工作,我想调查它为什么会发生。
锁定释放时如何订阅事件?
shedlock 尝试获取锁多长时间?
附言
someInterval = 30 分钟
lockConfiguration: atleast = 5 min, atMost=20min