diff --git a/scheduler/boot-shedlock-sample/.mvn/wrapper/maven-wrapper.properties b/scheduler/boot-shedlock-sample/.mvn/wrapper/maven-wrapper.properties index eacdc9ed1..346d645fd 100644 --- a/scheduler/boot-shedlock-sample/.mvn/wrapper/maven-wrapper.properties +++ b/scheduler/boot-shedlock-sample/.mvn/wrapper/maven-wrapper.properties @@ -14,5 +14,5 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar diff --git a/scheduler/boot-shedlock-sample/src/main/java/com/learning/shedlock/config/LockConfig.java b/scheduler/boot-shedlock-sample/src/main/java/com/learning/shedlock/config/LockConfig.java new file mode 100644 index 000000000..748b32a2f --- /dev/null +++ b/scheduler/boot-shedlock-sample/src/main/java/com/learning/shedlock/config/LockConfig.java @@ -0,0 +1,24 @@ +package com.learning.shedlock.config; + +import javax.sql.DataSource; +import net.javacrumbs.shedlock.core.LockProvider; +import net.javacrumbs.shedlock.provider.jdbctemplate.JdbcTemplateLockProvider; +import net.javacrumbs.shedlock.spring.annotation.EnableSchedulerLock; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.scheduling.annotation.EnableScheduling; + +@Configuration +@EnableScheduling +@EnableSchedulerLock(defaultLockAtMostFor = "PT2M") +public class LockConfig { + + @Bean + LockProvider scheduledJobLockProvider(DataSource dataSource) { + return new JdbcTemplateLockProvider(JdbcTemplateLockProvider.Configuration.builder() + .withJdbcTemplate(new JdbcTemplate(dataSource)) + .usingDbTime() + .build()); + } +}