Skip to content

Commit

Permalink
[SAMBAD-250] shedlock 기반 스케쥴러 락 도입 (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
kkjsw17 authored Aug 16, 2024
1 parent 38de02d commit cdfac23
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ dependencies {

implementation 'org.apache.poi:poi:4.1.2'
implementation 'org.apache.poi:poi-ooxml:4.1.2'

implementation 'net.javacrumbs.shedlock:shedlock-spring:5.14.0'
implementation 'net.javacrumbs.shedlock:shedlock-provider-jdbc-template:5.14.0'
}

test {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
package org.depromeet.sambad.moring.common.config;

import javax.sql.DataSource;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;

import net.javacrumbs.shedlock.core.LockProvider;
import net.javacrumbs.shedlock.provider.jdbctemplate.JdbcTemplateLockProvider;
import net.javacrumbs.shedlock.spring.annotation.EnableSchedulerLock;

@Configuration
@EnableScheduling
@EnableSchedulerLock(defaultLockAtMostFor = "PT30S")
public class SchedulingConfig {

@Bean
public LockProvider lockProvider(DataSource dataSource) {
return new JdbcTemplateLockProvider(dataSource);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

Expand All @@ -24,7 +26,8 @@ public class MeetingQuestionStatusCheckScheduler {
private final MeetingQuestionRepository meetingQuestionRepository;
private final EventService eventService;

@Scheduled(fixedDelay = 1000 * 5)
@Scheduled(fixedDelay = 10 * 1000)
@SchedulerLock(name = "meetingQuestionStatus", lockAtLeastFor = "PT10S", lockAtMostFor = "PT30S")
@Transactional
public void inactivate() {
// 활성 상태이지만 만료 시간이 지나 INACTIVE 상태가 되어야 하는 질문 목록 조회
Expand Down

0 comments on commit cdfac23

Please sign in to comment.