parent
e470e70612
commit
c1748001d5
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue