如何在 Spring Integration 中使用 ShedLock?

问题描述

我正在结合 Spring Batch 和 Spring Integration,我正在使用带有玉米的轮询器:

@Bean
@SchedulerLock(name = "importEntitiesRiskCodes",lockAtMostForString = "PT5M")
public IntegrationFlow integrationFlow() {
    return IntegrationFlows.from(fileReadingMessageSource(),c -> c.poller(Pollers.cron("0-7 1-59/5 * * * ?").maxMessagesPerPoll(maxFilesPerPoll)))
            .channel(fileIn())
            .transform(fileMessagetoJobrequest())
            .handle(jobLaunchingGateway())
            .log()
            .get();
}

我知道 Spring Integration JDBC 提供了 JDBCLockRepository,但我想知道如何使用 ShedLock。

解决方法

从您的描述中根本不清楚您将如何使用该锁,但根据此 article,看起来与 Spring Integration 无关。

另一方面,即使我不熟悉库,将 ShedLock 的 LockRegistry 实现添加到 Spring Integration 中也不错。尽管它可能与您的任务无关...