diff --git a/backend/pium/src/main/java/com/official/pium/admin/service/TestService.java b/backend/pium/src/main/java/com/official/pium/admin/service/TestService.java index 0f4228e4..faf30fd6 100644 --- a/backend/pium/src/main/java/com/official/pium/admin/service/TestService.java +++ b/backend/pium/src/main/java/com/official/pium/admin/service/TestService.java @@ -33,6 +33,23 @@ public class TestService { // log.info("동기 알림 테스트 종료. Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName()); // } + public void sendWaterNotificationAsyncRampTest() { + List petPlants = petPlantRepository.findAllByMemberId(7L); + List events = petPlants.stream() + .map(plant -> NotificationEvent.builder() + .title(plant.getNickname()) + .body("(테스트 중) 물을 줄 시간이에요!") + .deviceToken(plant.getMember().getDeviceToken()) + .build() + ).toList(); + + log.info("비동기 테스트 램프업 시작"); + for (int i = 0; i < 40; i++) { + NotificationEvent notificationEvent = events.get(i); + publisher.publishEvent(notificationEvent); + } + } + public void sendWaterNotificationAsyncTest() { List petPlants = petPlantRepository.findAllByMemberId(7L); List events = petPlants.stream() diff --git a/backend/pium/src/main/java/com/official/pium/admin/ui/TestController.java b/backend/pium/src/main/java/com/official/pium/admin/ui/TestController.java index c2fae203..dedbf872 100644 --- a/backend/pium/src/main/java/com/official/pium/admin/ui/TestController.java +++ b/backend/pium/src/main/java/com/official/pium/admin/ui/TestController.java @@ -26,6 +26,12 @@ public class TestController { // return ResponseEntity.ok("알림 기능 테스트 성공"); // } + @GetMapping("/notifications/ramp") + public ResponseEntity notificationRampTest() { + testService.sendWaterNotificationAsyncRampTest(); + return ResponseEntity.ok("비동기 알림 기능 테스트 램프업 성공"); + } + @GetMapping("/notifications/async") public ResponseEntity notificationAsyncTest() { testService.sendWaterNotificationAsyncTest(); diff --git a/backend/pium/src/main/java/com/official/pium/config/AsyncConfig.java b/backend/pium/src/main/java/com/official/pium/config/AsyncConfig.java index 52810b3e..14dc77a2 100644 --- a/backend/pium/src/main/java/com/official/pium/config/AsyncConfig.java +++ b/backend/pium/src/main/java/com/official/pium/config/AsyncConfig.java @@ -13,7 +13,7 @@ public class AsyncConfig implements AsyncConfigurer { @Override public Executor getAsyncExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - executor.setCorePoolSize(20); + executor.setCorePoolSize(30); // executor.setQueueCapacity(15); // executor.setMaxPoolSize(200); executor.setThreadNamePrefix("2024-Pium-Thread: ");