test #243

Merged
klaus merged 13 commits from test into main 2024-12-02 04:29:50 +00:00
3 changed files with 2 additions and 34 deletions
Showing only changes of commit e470e70612 - Show all commits

View File

@ -34,7 +34,6 @@ dependencies {
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.springframework.retry:spring-retry")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.redisson:redisson-spring-boot-starter:3.17.7")
// jwt
implementation("io.jsonwebtoken:jjwt-api:0.11.5")

View File

@ -1,8 +1,5 @@
package kr.co.vividnext.sodalive.configs
import org.redisson.Redisson
import org.redisson.api.RedissonClient
import org.redisson.config.Config
import org.springframework.beans.factory.annotation.Value
import org.springframework.cache.annotation.EnableCaching
import org.springframework.context.annotation.Bean
@ -29,17 +26,6 @@ class RedisConfig(
@Value("\${spring.redis.port}")
private val port: Int
) {
@Bean
fun redissonClient(): RedissonClient {
val config = Config()
config.useSingleServer()
.setAddress("redis://$host:$port")
.setConnectionMinimumIdleSize(1) // 최소 유휴 연결: 1
.setConnectionPoolSize(5) // 최대 연결 풀 크기: 5
return Redisson.create(config)
}
@Bean
fun redisConnectionFactory(): RedisConnectionFactory {
val clientConfiguration = LettuceClientConfiguration.builder()

View File

@ -1,32 +1,15 @@
package kr.co.vividnext.sodalive.scheduler
import kr.co.vividnext.sodalive.content.AudioContentService
import org.redisson.api.RedissonClient
import org.springframework.scheduling.annotation.Scheduled
import org.springframework.stereotype.Service
import java.util.concurrent.TimeUnit
@Service
class AudioContentReleaseSchedulerService(
private val redissonClient: RedissonClient,
private val audioContentService: AudioContentService
) {
@Scheduled(fixedRate = 1000 * 60 * 5)
@Scheduled(cron = "0 0/15 * * * *")
fun release() {
val lock = redissonClient.getLock("lock:audioContentRelease")
if (lock.tryLock(10, TimeUnit.SECONDS)) {
try {
println("락을 획득하여 배포를 시작합니다.")
audioContentService.releaseContent()
} finally {
if (lock.isHeldByCurrentThread) {
lock.unlock()
println("락 해제")
}
}
} else {
println("락을 획득하지 못해서 배포를 건너뜁니다")
}
}
}