Skip to content
Snippets Groups Projects
Commit 2f0f6354 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-6867 OZG-6909 add shedlock configuration

parent 88a15533
No related branches found
No related tags found
No related merge requests found
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
<lombok-mapstruct-binding.version>0.2.0</lombok-mapstruct-binding.version> <lombok-mapstruct-binding.version>0.2.0</lombok-mapstruct-binding.version>
<mapstruct-processor.version>${mapstruct.version}</mapstruct-processor.version> <mapstruct-processor.version>${mapstruct.version}</mapstruct-processor.version>
<zufi-manager.version>1.5.0-SNAPSHOT</zufi-manager.version> <zufi-manager.version>1.5.0-SNAPSHOT</zufi-manager.version>
<shedlock.version>5.16.0</shedlock.version>
</properties> </properties>
<dependencies> <dependencies>
...@@ -85,6 +86,18 @@ ...@@ -85,6 +86,18 @@
<artifactId>grpc-client-spring-boot-starter</artifactId> <artifactId>grpc-client-spring-boot-starter</artifactId>
</dependency> </dependency>
<!-- ShedLock -->
<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-spring</artifactId>
<version>${shedlock.version}</version>
</dependency>
<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-provider-mongo</artifactId>
<version>${shedlock.version}</version>
</dependency>
<!-- Keycloak --> <!-- Keycloak -->
<dependency> <dependency>
<groupId>org.keycloak</groupId> <groupId>org.keycloak</groupId>
......
package de.ozgcloud.admin; package de.ozgcloud.admin;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import com.mongodb.client.MongoClient;
import net.javacrumbs.shedlock.core.LockProvider;
import net.javacrumbs.shedlock.provider.mongo.MongoLockProvider;
import net.javacrumbs.shedlock.spring.annotation.EnableSchedulerLock;
@Configuration @Configuration
@EnableScheduling @EnableScheduling
@EnableSchedulerLock(defaultLockAtMostFor = "PT23H")
public class SchedulingConfiguration { public class SchedulingConfiguration {
@Value("${spring.data.mongodb.database}")
private String database;
@Bean
LockProvider lockProvider(MongoClient mongoClient) {
return new MongoLockProvider(mongoClient.getDatabase(database));
}
} }
...@@ -4,6 +4,7 @@ import org.springframework.scheduling.annotation.Scheduled; ...@@ -4,6 +4,7 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
@Component @Component
@RequiredArgsConstructor @RequiredArgsConstructor
...@@ -11,6 +12,7 @@ class SyncScheduler { ...@@ -11,6 +12,7 @@ class SyncScheduler {
private final SyncService syncService; private final SyncService syncService;
@SchedulerLock(name = "SyncScheduler_syncOrganisationsEinheitenFromKeycloak", lockAtLeastFor = "PT5M", lockAtMostFor = "PT23H")
@Scheduled(cron = "${ozgcloud.administration.sync.organisationseinheiten.cron}") @Scheduled(cron = "${ozgcloud.administration.sync.organisationseinheiten.cron}")
public void syncOrganisationsEinheitenFromKeycloak() { public void syncOrganisationsEinheitenFromKeycloak() {
syncService.syncOrganisationsEinheitenFromKeycloak(); syncService.syncOrganisationsEinheitenFromKeycloak();
......
...@@ -2,6 +2,7 @@ spring: ...@@ -2,6 +2,7 @@ spring:
data: data:
mongodb: mongodb:
uri: mongodb://localhost:27017/config-db uri: mongodb://localhost:27017/config-db
database: config-db
security: security:
user: user:
name: user name: user
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment