From da503fef439296e5fe49a0ab37243e59cc088a4c Mon Sep 17 00:00:00 2001 From: kanghana1 Date: Sat, 16 May 2026 18:04:30 +0900 Subject: [PATCH 1/2] =?UTF-8?q?chore:=20=EB=A1=9C=EA=B7=B8=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cockple/demo/domain/notification/fcm/FcmService.java | 6 ++++-- .../notification/service/NotificationCommandService.java | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/umc/cockple/demo/domain/notification/fcm/FcmService.java b/src/main/java/umc/cockple/demo/domain/notification/fcm/FcmService.java index 5785e27cb..10051593b 100644 --- a/src/main/java/umc/cockple/demo/domain/notification/fcm/FcmService.java +++ b/src/main/java/umc/cockple/demo/domain/notification/fcm/FcmService.java @@ -46,8 +46,9 @@ public void sendNotification(Member member, String title, String content) { .build(); try { + long start = System.currentTimeMillis(); firebaseMessaging.send(message); - log.info("FCM 전송 완료 - memberId: {}", member.getId()); + log.info("[FCM] 일반 알림 전송 완료 - memberId: {}, 소요시간: {}ms", member.getId(), System.currentTimeMillis() - start); } catch (FirebaseMessagingException e) { log.error("FCM 전송 실패 - memberId: {}, error: {}", member.getId(), e.getMessage()); } @@ -72,8 +73,9 @@ public void sendChatNotification(Member member, String title, String content, .build(); try { + long start = System.currentTimeMillis(); firebaseMessaging.send(message); - log.info("채팅 FCM 전송 완료 - memberId: {}, chatRoomId: {}", member.getId(), chatRoomId); + log.info("[FCM] 채팅 알림 전송 완료 - memberId: {}, chatRoomId: {}, 소요시간: {}ms", member.getId(), chatRoomId, System.currentTimeMillis() - start); } catch (FirebaseMessagingException e) { log.error("채팅 FCM 전송 실패 - memberId: {}, error: {}", member.getId(), e.getMessage()); } diff --git a/src/main/java/umc/cockple/demo/domain/notification/service/NotificationCommandService.java b/src/main/java/umc/cockple/demo/domain/notification/service/NotificationCommandService.java index f62a4d6f5..69b0a45a0 100644 --- a/src/main/java/umc/cockple/demo/domain/notification/service/NotificationCommandService.java +++ b/src/main/java/umc/cockple/demo/domain/notification/service/NotificationCommandService.java @@ -61,7 +61,7 @@ public Response markAsReadNotification(Long memberId, Long notificationId, Notif public void createNotification(CreateNotificationRequestDTO dto) { try { - + long start = System.currentTimeMillis(); Member member = dto.member(); List bookmarks = notificationRepository.findAllByMemberOrderByCreatedAtDesc(member); if (bookmarks.size() >= 50) { @@ -119,7 +119,11 @@ public void createNotification(CreateNotificationRequestDTO dto) { .build(); notificationRepository.save(notification); + long dbTime = System.currentTimeMillis() - start; + log.info("[NOTIFICATION] DB 저장 완료 - memberId: {}, 소요시간: {}ms", member.getId(), dbTime); + fcmService.sendNotification(member, title, content); + log.info("[NOTIFICATION] 전체 알림 생성 완료 - memberId: {}, 총 소요시간: {}ms", member.getId(), System.currentTimeMillis() - start); } catch (JsonProcessingException e) { throw new NotificationException(NotificationErrorCode.INVALID_NOTIFICATION_DATA); From 40bc97263522b0040381c362e8347a1d98b243ad Mon Sep 17 00:00:00 2001 From: kanghana1 Date: Sun, 17 May 2026 15:50:18 +0900 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EC=9A=A9=20=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NotificationLoadTestController.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/main/java/umc/cockple/demo/domain/notification/controller/NotificationLoadTestController.java diff --git a/src/main/java/umc/cockple/demo/domain/notification/controller/NotificationLoadTestController.java b/src/main/java/umc/cockple/demo/domain/notification/controller/NotificationLoadTestController.java new file mode 100644 index 000000000..10dd7191b --- /dev/null +++ b/src/main/java/umc/cockple/demo/domain/notification/controller/NotificationLoadTestController.java @@ -0,0 +1,45 @@ +package umc.cockple.demo.domain.notification.controller; + +import lombok.RequiredArgsConstructor; +import org.springframework.context.annotation.Profile; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import umc.cockple.demo.domain.member.domain.Member; +import umc.cockple.demo.domain.member.exception.MemberErrorCode; +import umc.cockple.demo.domain.member.exception.MemberException; +import umc.cockple.demo.domain.member.repository.MemberRepository; +import umc.cockple.demo.domain.notification.dto.CreateNotificationRequestDTO; +import umc.cockple.demo.domain.notification.enums.NotificationTarget; +import umc.cockple.demo.domain.notification.service.NotificationCommandService; +import umc.cockple.demo.global.response.BaseResponse; +import umc.cockple.demo.global.response.code.status.CommonSuccessCode; +import umc.cockple.demo.global.security.utils.SecurityUtil; + +@RestController +@RequestMapping("/api/test") +@RequiredArgsConstructor +@Profile("staging") +public class NotificationLoadTestController { + + private final NotificationCommandService notificationCommandService; + private final MemberRepository memberRepository; + + @PostMapping("/notification") + public BaseResponse testNotification(@RequestParam Long partyId) { + Long memberId = SecurityUtil.getCurrentMemberId(); + Member member = memberRepository.findById(memberId) + .orElseThrow(() -> new MemberException(MemberErrorCode.MEMBER_NOT_FOUND)); + + notificationCommandService.createNotification( + CreateNotificationRequestDTO.builder() + .member(member) + .partyId(partyId) + .target(NotificationTarget.PARTY_MODIFY) + .build() + ); + + return BaseResponse.success(CommonSuccessCode.OK, null); + } +}