Skip to content

Commit

Permalink
[Feat] : redisson 환경변수 상수처리
Browse files Browse the repository at this point in the history
  • Loading branch information
wellbeing-dough committed Jul 20, 2024
1 parent 40c4077 commit 08ba1a4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
public class RedissonDistributedLockAop {

private final RedissonClient redissonClient;
private static final int LOCK_WAIT_TIME = 10;
private static final int LOCK_LEASE_TIME = 3;

@Around("@annotation(kr.co.studyhubinu.studyhubserver.common.redisson.RedissonDistributedLock)")
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
Expand All @@ -35,7 +37,7 @@ public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
Object result;
boolean available = false;
try {
available = lock.tryLock(10, 3, TimeUnit.SECONDS);
available = lock.tryLock(LOCK_WAIT_TIME, LOCK_LEASE_TIME, TimeUnit.SECONDS);
if (!available) {
log.warn("Redisson GetLock Timeout {}", field);
throw new StudyApplyLockAcquisitionException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@
import kr.co.studyhubinu.studyhubserver.common.redisson.RedissonDistributedLock;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RedissonClient;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
@Slf4j
public class StudyPostApplyEventPublisher {

private final RedissonClient redissonClient;
private final StudyPostWriter studyPostWriter;
private final StudyPostReader studyPostReader;

@RedissonDistributedLock(hashKey = "'apply'", field = "#studyPostId")
public void acceptApplyEventPublish(Long studyPostId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;

@SpringBootTest
@Disabled
class StudyPostApplyEventPublisherTest {

@Autowired
Expand Down

0 comments on commit 08ba1a4

Please sign in to comment.