From 95be8bf2842dc0fcff19c26203427362e23a66c0 Mon Sep 17 00:00:00 2001 From: "Jaemin.Park" Date: Thu, 21 Dec 2023 16:20:39 +0900 Subject: [PATCH] Configure SchedulerConfig --- .../raisedragon/config/AsyncConfig.kt | 22 +++++++++++++++++++ .../raisedragon/config/SchedulerConfig.kt | 11 ++++++++++ .../scheduler/SchedulerBasePackage.kt | 3 +++ 3 files changed, 36 insertions(+) create mode 100644 raisedragon-api/src/main/kotlin/com/whatever/raisedragon/config/AsyncConfig.kt create mode 100644 raisedragon-api/src/main/kotlin/com/whatever/raisedragon/config/SchedulerConfig.kt create mode 100644 raisedragon-api/src/main/kotlin/com/whatever/raisedragon/scheduler/SchedulerBasePackage.kt diff --git a/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/config/AsyncConfig.kt b/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/config/AsyncConfig.kt new file mode 100644 index 0000000..1f63cc8 --- /dev/null +++ b/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/config/AsyncConfig.kt @@ -0,0 +1,22 @@ +package com.whatever.raisedragon.config + +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.scheduling.annotation.EnableAsync +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor +import java.util.concurrent.Executor + +@Configuration +@EnableAsync +class AsyncConfig { + @Bean(name = ["asyncSchedulerExecutor"]) + fun asyncSchedulerExecutor(): Executor { + return ThreadPoolTaskExecutor().apply { + corePoolSize = 5 + maxPoolSize = 5 + queueCapacity = 20 + setThreadNamePrefix("AsyncSchedulerThread-") + setWaitForTasksToCompleteOnShutdown(true) + } + } +} \ No newline at end of file diff --git a/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/config/SchedulerConfig.kt b/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/config/SchedulerConfig.kt new file mode 100644 index 0000000..0739306 --- /dev/null +++ b/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/config/SchedulerConfig.kt @@ -0,0 +1,11 @@ +package com.whatever.raisedragon.config + +import com.whatever.raisedragon.scheduler.SchedulerBasePackage +import org.springframework.context.annotation.ComponentScan +import org.springframework.context.annotation.Configuration +import org.springframework.scheduling.annotation.EnableScheduling + +@Configuration +@EnableScheduling +@ComponentScan(basePackageClasses = [SchedulerBasePackage::class]) +class SchedulerConfig \ No newline at end of file diff --git a/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/scheduler/SchedulerBasePackage.kt b/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/scheduler/SchedulerBasePackage.kt new file mode 100644 index 0000000..e23e841 --- /dev/null +++ b/raisedragon-api/src/main/kotlin/com/whatever/raisedragon/scheduler/SchedulerBasePackage.kt @@ -0,0 +1,3 @@ +package com.whatever.raisedragon.scheduler + +interface SchedulerBasePackage \ No newline at end of file