From 2abf81f6f38dd4d14127c9d547f2953ad7f77c0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EC=84=B8=EC=A4=80?= <74056843+sejoon00@users.noreply.github.com> Date: Wed, 14 Aug 2024 00:39:36 +0900 Subject: [PATCH] [fix][#28]cherry pick --- .../scheduler/SchedulerConfiguration.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/main/java/com/server/bbo_gak/global/config/scheduler/SchedulerConfiguration.java diff --git a/src/main/java/com/server/bbo_gak/global/config/scheduler/SchedulerConfiguration.java b/src/main/java/com/server/bbo_gak/global/config/scheduler/SchedulerConfiguration.java new file mode 100644 index 0000000..144355f --- /dev/null +++ b/src/main/java/com/server/bbo_gak/global/config/scheduler/SchedulerConfiguration.java @@ -0,0 +1,26 @@ +package com.server.bbo_gak.global.config.scheduler; + +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.SchedulingConfigurer; +import org.springframework.scheduling.config.ScheduledTaskRegistrar; + +@Configuration +public class SchedulerConfiguration implements SchedulingConfigurer { + + @Value("${scheduler.thread.pool.size}") + private int poolSize; + + @Override + public void configureTasks(ScheduledTaskRegistrar taskRegistrar) { + taskRegistrar.setScheduler(taskScheduler()); + } + + @Bean(destroyMethod = "shutdown") + public ScheduledExecutorService taskScheduler() { + return Executors.newScheduledThreadPool(poolSize); + } +}