diff --git a/core/core-api/src/main/java/cmc/mellyserver/common/aspect/lock/OptimisticLockAspect.java b/core/core-api/src/main/java/cmc/mellyserver/common/aspect/lock/OptimisticLockAspect.java index 2f53a9d1..a16c8729 100644 --- a/core/core-api/src/main/java/cmc/mellyserver/common/aspect/lock/OptimisticLockAspect.java +++ b/core/core-api/src/main/java/cmc/mellyserver/common/aspect/lock/OptimisticLockAspect.java @@ -30,7 +30,7 @@ @Slf4j @Aspect @Component -@Order(Ordered.LOWEST_PRECEDENCE - 2) // @Transaction보다 먼저 AOP가 호출 +@Order(Ordered.LOWEST_PRECEDENCE - 2) @RequiredArgsConstructor public class OptimisticLockAspect { diff --git a/core/core-api/src/main/java/cmc/mellyserver/controller/group/GroupController.java b/core/core-api/src/main/java/cmc/mellyserver/controller/group/GroupController.java index e093f63d..20fb7524 100644 --- a/core/core-api/src/main/java/cmc/mellyserver/controller/group/GroupController.java +++ b/core/core-api/src/main/java/cmc/mellyserver/controller/group/GroupController.java @@ -57,7 +57,8 @@ public ResponseEntity> updateGroup(@PathVariable Long groupId, public ResponseEntity> joinGroup(@CurrentUser LoginUser loginUser, @PathVariable(name = "groupId") Long groupId) { - groupService.joinGroup(loginUser.getId(), groupId); + int i = groupService.joinGroup(loginUser.getId(), groupId); + System.out.println(i); return ApiResponse.success(SuccessCode.INSERT_SUCCESS); } diff --git a/core/core-api/src/main/java/cmc/mellyserver/controller/health/HealthCheckController.java b/core/core-api/src/main/java/cmc/mellyserver/controller/health/HealthCheckController.java new file mode 100644 index 00000000..e1f41c58 --- /dev/null +++ b/core/core-api/src/main/java/cmc/mellyserver/controller/health/HealthCheckController.java @@ -0,0 +1,14 @@ +package cmc.mellyserver.controller.health; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HealthCheckController { + + @GetMapping("/api/health") + public ResponseEntity healthCheck() { + return ResponseEntity.ok("health up"); + } +} diff --git a/core/core-api/src/main/java/cmc/mellyserver/domain/comment/CommentLikeService.java b/core/core-api/src/main/java/cmc/mellyserver/domain/comment/CommentLikeService.java index 201f40a0..4f0e8ef2 100644 --- a/core/core-api/src/main/java/cmc/mellyserver/domain/comment/CommentLikeService.java +++ b/core/core-api/src/main/java/cmc/mellyserver/domain/comment/CommentLikeService.java @@ -21,19 +21,19 @@ public class CommentLikeService { private final CommentReader commentReader; - @DistributedLock(key = "#commentId") // 대부분은 분산락으로 처리 - @OptimisticLock(retryCount = 3, waitTime = 1000L) // 만약의 경우를 대비해서 낙관적락도 걸기 + @OptimisticLock + @DistributedLock(key = "#commentId") @Transactional public void saveCommentLike(final Long userId, final Long commentId) { - Comment comment = commentReader.findByIdWithLock(commentId); // 댓글 조회 (비관적 락) - commentLikeValidator.validateDuplicatedLike(commentId, userId); // commentLike 테이블 조회 -> 자신이 좋아요를 눌렀는지 기록 필요 + Comment comment = commentReader.findByIdWithLock(commentId); + commentLikeValidator.validateDuplicatedLike(commentId, userId); comment.addLike(); commentLikeWriter.save(userId, comment); } - @DistributedLock(key = "#commentId") // 대부분은 분산락으로 처리 - @OptimisticLock(retryCount = 3, waitTime = 1000L) // 만약의 경우를 대비해서 낙관적락도 걸기 + @OptimisticLock + @DistributedLock(key = "#commentId") @Transactional public void deleteCommentLike(final Long userId, final Long commentId) { diff --git a/core/core-api/src/main/java/cmc/mellyserver/domain/group/GroupService.java b/core/core-api/src/main/java/cmc/mellyserver/domain/group/GroupService.java index 3a597fcd..4e0da2fd 100644 --- a/core/core-api/src/main/java/cmc/mellyserver/domain/group/GroupService.java +++ b/core/core-api/src/main/java/cmc/mellyserver/domain/group/GroupService.java @@ -68,12 +68,13 @@ public Long saveGroup(Long userId, CreateGroupRequestDto createGroupRequestDto) @OptimisticLock @CacheEvict(cacheNames = CacheNames.GROUP, key = "#groupId") @Transactional - public void joinGroup(final Long userId, final Long groupId) { + public int joinGroup(final Long userId, final Long groupId) { UserGroup userGroup = groupReader.readWithLock(groupId); groupValidator.isMaximumGroupMember(groupId); groupValidator.isDuplicatedJoin(userId, userGroup.getId()); groupAndUserWriter.save(GroupAndUser.of(userId, userGroup)); + return 1; } @CacheEvict(cacheNames = CacheNames.GROUP, key = "#updateGroupRequestDto.groupId") diff --git a/storage/db-redis/src/main/java/cmc/mellyserver/dbredis/config/RedisConfig.java b/storage/db-redis/src/main/java/cmc/mellyserver/dbredis/config/RedisConfig.java index 345ec754..bf3b0f1e 100644 --- a/storage/db-redis/src/main/java/cmc/mellyserver/dbredis/config/RedisConfig.java +++ b/storage/db-redis/src/main/java/cmc/mellyserver/dbredis/config/RedisConfig.java @@ -39,8 +39,7 @@ public RedissonClient redissonClient() { Config config = new Config(); config.useSingleServer() .setAddress(REDISSON_HOST_PREFIX + host + ":" + port) - .setRetryAttempts(2) - .setRetryInterval(500); + .setConnectTimeout(3000); return Redisson.create(config); }