diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/SodaLiveApplication.kt b/src/main/kotlin/kr/co/vividnext/sodalive/SodaLiveApplication.kt index d160bf6..78fe613 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/SodaLiveApplication.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/SodaLiveApplication.kt @@ -4,10 +4,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication import org.springframework.retry.annotation.EnableRetry import org.springframework.scheduling.annotation.EnableAsync -import org.springframework.scheduling.annotation.EnableScheduling @SpringBootApplication -@EnableScheduling @EnableAsync @EnableRetry class SodaLiveApplication diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/common/annotation/SchedulerOnly.kt b/src/main/kotlin/kr/co/vividnext/sodalive/common/annotation/AudioContentReleaseSchedulerOnly.kt similarity index 75% rename from src/main/kotlin/kr/co/vividnext/sodalive/common/annotation/SchedulerOnly.kt rename to src/main/kotlin/kr/co/vividnext/sodalive/common/annotation/AudioContentReleaseSchedulerOnly.kt index 2c29ee8..28340bc 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/common/annotation/SchedulerOnly.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/common/annotation/AudioContentReleaseSchedulerOnly.kt @@ -6,13 +6,13 @@ import org.springframework.stereotype.Component @Target(AnnotationTarget.FUNCTION) @Retention(AnnotationRetention.RUNTIME) -annotation class SchedulerOnly +annotation class AudioContentReleaseSchedulerOnly @Aspect @Component class SchedulerOnlyAspect { - @Before("@annotation(SchedulerOnly)") + @Before("@annotation(AudioContentReleaseSchedulerOnly)") fun checkSchedulerAccess() { if (!isSchedulerThread()) { throw IllegalStateException("잘못된 접근입니다.") @@ -21,6 +21,6 @@ class SchedulerOnlyAspect { private fun isSchedulerThread(): Boolean { // 스케줄러 스레드 여부를 판단하는 간단한 로직 - return Thread.currentThread().name.contains("scheduler") + return Thread.currentThread().name.contains("AudioContentRelease-Scheduler") } } diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/configs/SchedulerConfig.kt b/src/main/kotlin/kr/co/vividnext/sodalive/configs/SchedulerConfig.kt new file mode 100644 index 0000000..116acc6 --- /dev/null +++ b/src/main/kotlin/kr/co/vividnext/sodalive/configs/SchedulerConfig.kt @@ -0,0 +1,18 @@ +package kr.co.vividnext.sodalive.configs + +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.scheduling.annotation.EnableScheduling +import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler + +@Configuration +@EnableScheduling +class SchedulerConfig { + @Bean + fun taskScheduler(): ThreadPoolTaskScheduler { + val scheduler = ThreadPoolTaskScheduler() + scheduler.poolSize = 2 + scheduler.setThreadNamePrefix("AudioContentRelease-Scheduler-") + return scheduler + } +} diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentService.kt index 1902782..05f9738 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/content/AudioContentService.kt @@ -5,7 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper import kr.co.vividnext.sodalive.aws.cloudfront.AudioContentCloudFront import kr.co.vividnext.sodalive.aws.s3.S3Uploader import kr.co.vividnext.sodalive.common.SodaException -import kr.co.vividnext.sodalive.common.annotation.SchedulerOnly +import kr.co.vividnext.sodalive.common.annotation.AudioContentReleaseSchedulerOnly import kr.co.vividnext.sodalive.content.comment.AudioContentCommentRepository import kr.co.vividnext.sodalive.content.hashtag.AudioContentHashTag import kr.co.vividnext.sodalive.content.hashtag.HashTag @@ -403,7 +403,7 @@ class AudioContentService( } } - @SchedulerOnly + @AudioContentReleaseSchedulerOnly @Transactional fun releaseContent() { val notReleasedAudioContent = repository.getNotReleaseContent()