Skip to content

Commit

Permalink
#45 [Add] ShedLock 추가, TimeZone 설정 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
JSoi committed Jul 31, 2022
1 parent f0c48ea commit c7e744a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/main/java/com/mpnp/baechelin/BaechelinApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableScheduling;

import javax.annotation.PostConstruct;
import java.util.TimeZone;


@EnableJpaAuditing
@EnableConfigurationProperties({
Expand All @@ -25,4 +28,9 @@ public class BaechelinApplication {
public static void main(String[] args) {
SpringApplication.run(BaechelinApplication.class, args);
}
@PostConstruct
public void started() {
// timezone UTC 셋팅
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Seoul"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.javacrumbs.shedlock.provider.jdbctemplate.JdbcTemplateLockProvider;

import javax.sql.DataSource;
import java.util.TimeZone;


@Configuration
Expand All @@ -16,7 +17,7 @@ public LockProvider lockProvider(DataSource dataSource) {
return new JdbcTemplateLockProvider(
JdbcTemplateLockProvider.Configuration.builder()
.withJdbcTemplate(new JdbcTemplate(dataSource))
.usingDbTime()
.withTimeZone(TimeZone.getTimeZone("Asia/Seoul"))
.build()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,10 @@ public List<StoreCardResponseDto> searchStores(String sido, String sigungu, Stri
return result;
}

@Scheduled(cron = "0 0 0-23 * * *")
@SchedulerLock(name = "updateScheduler",
lockAtLeastFor = "PT30M", lockAtMostFor = "PT59M")
@Scheduled(cron = "0 0 0-23 * * *") // 1시간에 한 번
@SchedulerLock(name = "updateScheduler", lockAtLeastFor = "PT58M", lockAtMostFor = "PT30M")
public void updateSchedule() {
log.info("AVG, BOOKMARK COUNT SCHEDULING");
List<Store> storeList = storeRepository.findAll();
for (Store store : storeList) {
if (!store.getReviewList().isEmpty()) {
Expand Down

0 comments on commit c7e744a

Please sign in to comment.