From 5d332288e159201a7d3d89eba9793c0276e55933 Mon Sep 17 00:00:00 2001 From: jeongchanmin Date: Wed, 24 Jul 2024 15:51:20 +0900 Subject: [PATCH 1/3] =?UTF-8?q?:recycle:=20[Refactor]=20sql=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=20=EC=B6=9C=EB=A0=A5=EB=AC=B8=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index f81a65e..a942596 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -7,7 +7,7 @@ spring: jpa: database: mysql database-platform: org.hibernate.dialect.MySQLDialect - show-sql: true + show-sql: false hibernate: ddl-auto: update properties: From d62719cc911ca6c4c5fbc4c71430de403ca146b6 Mon Sep 17 00:00:00 2001 From: jeongchanmin Date: Wed, 24 Jul 2024 15:51:57 +0900 Subject: [PATCH 2/3] =?UTF-8?q?:sparkles:=20[Feat]=20=EC=98=81=ED=99=94=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20?= =?UTF-8?q?=EC=9E=90=EB=8F=99=ED=99=94=20=EC=8A=A4=EC=BC=80=EC=A4=84?= =?UTF-8?q?=EB=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WatchWithMe/WatchWithMeApplication.java | 2 + .../global/config/SchedulerConfig.java | 42 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 src/main/java/WatchWithMe/global/config/SchedulerConfig.java diff --git a/src/main/java/WatchWithMe/WatchWithMeApplication.java b/src/main/java/WatchWithMe/WatchWithMeApplication.java index 196fec9..a230aff 100644 --- a/src/main/java/WatchWithMe/WatchWithMeApplication.java +++ b/src/main/java/WatchWithMe/WatchWithMeApplication.java @@ -2,8 +2,10 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.scheduling.annotation.EnableScheduling; @SpringBootApplication +@EnableScheduling public class WatchWithMeApplication { public static void main(String[] args) { diff --git a/src/main/java/WatchWithMe/global/config/SchedulerConfig.java b/src/main/java/WatchWithMe/global/config/SchedulerConfig.java new file mode 100644 index 0000000..79e054a --- /dev/null +++ b/src/main/java/WatchWithMe/global/config/SchedulerConfig.java @@ -0,0 +1,42 @@ +package WatchWithMe.global.config; + +import WatchWithMe.global.exception.GlobalException; +import WatchWithMe.global.exception.code.GlobalErrorCode; +import WatchWithMe.service.MovieService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.scheduling.annotation.SchedulingConfigurer; +import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; +import org.springframework.scheduling.config.ScheduledTaskRegistrar; + +@Slf4j +@Configuration +@RequiredArgsConstructor +public class SchedulerConfig implements SchedulingConfigurer { + + private final int POOL_SIZE = 10; // 스레드 풀 사이즈 + private final MovieService movieService; + + @Scheduled(initialDelay=1000, fixedDelay=60000 * 5) // 5분 마다 수행 + public void updateMovieList() { + try { + movieService.updateMovieList(); + log.info("영화 정보 업데이트 완료"); + } catch (Exception e) { + throw new GlobalException(GlobalErrorCode._INTERNAL_SERVER_ERROR); + } + } + + // 여러 개의 스레드 동시 처리 + @Override + public void configureTasks(ScheduledTaskRegistrar taskRegistrar) { + final ThreadPoolTaskScheduler threadPoolTaskScheduler = new ThreadPoolTaskScheduler(); + threadPoolTaskScheduler.setPoolSize(POOL_SIZE); + threadPoolTaskScheduler.setThreadNamePrefix("test-scheduled-task-pool-"); + threadPoolTaskScheduler.initialize(); + + taskRegistrar.setTaskScheduler(threadPoolTaskScheduler); + } +} From 40450d0a2c018d045e36af4dafb68538ea567f91 Mon Sep 17 00:00:00 2001 From: jeongchanmin Date: Wed, 24 Jul 2024 15:52:24 +0900 Subject: [PATCH 3/3] =?UTF-8?q?:recycle:=20[Refactor]=20SecurityConfig=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/WatchWithMe/global/config/SecurityConfig.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/WatchWithMe/global/config/SecurityConfig.java b/src/main/java/WatchWithMe/global/config/SecurityConfig.java index 66be49f..b2fe631 100644 --- a/src/main/java/WatchWithMe/global/config/SecurityConfig.java +++ b/src/main/java/WatchWithMe/global/config/SecurityConfig.java @@ -53,7 +53,6 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { "/api/v1/actor/**", "/api/v1/director/**", "/api/v1/movie/**", - "api/v1/admin/**", "/health" ).permitAll() .requestMatchers("/api/v1/admin/**").hasAuthority("ADMIN")