From 7482a31330b2a07a7a7ac79610fc252c4505e922 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Sat, 6 Jan 2024 17:46:38 +0900 Subject: [PATCH 01/45] =?UTF-8?q?test:=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EC=9A=A9=20api=20=EC=88=98=EC=A0=95=20=EB=B0=8F=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 --- .../pium/admin/service/TestService.java | 53 +++++++++++++++++++ .../pium/admin/ui/AdminPageController.java | 8 --- .../pium/admin/ui/TestController.java | 34 ++++++++++++ .../NotificationEventListener.java | 12 +++++ .../petPlant/application/ReminderService.java | 13 ----- .../controller/AdminPageControllerTest.java | 4 -- 6 files changed, 99 insertions(+), 25 deletions(-) create mode 100644 backend/pium/src/main/java/com/official/pium/admin/service/TestService.java create mode 100644 backend/pium/src/main/java/com/official/pium/admin/ui/TestController.java 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 new file mode 100644 index 00000000..0cb6e6fb --- /dev/null +++ b/backend/pium/src/main/java/com/official/pium/admin/service/TestService.java @@ -0,0 +1,53 @@ +package com.official.pium.admin.service; + +import com.official.pium.petPlant.domain.PetPlant; +import com.official.pium.petPlant.event.notification.NotificationEvent; +import com.official.pium.petPlant.event.notification.NotificationEvents; +import com.official.pium.petPlant.repository.PetPlantRepository; +import java.util.List; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional(readOnly = true) +@RequiredArgsConstructor +@Slf4j +public class TestService { + + private final PetPlantRepository petPlantRepository; + private final ApplicationEventPublisher publisher; + + public void sendWaterNotificationTest() { + 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("동기 알림 테스트 시작. Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName()); + publisher.publishEvent(NotificationEvents.from(events)); + log.info("동기 알림 테스트 종료. Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName()); + } + + public void sendWaterNotificationAsyncTest() { + 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("비동기 알림 테스트 시작. Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName()); + for (NotificationEvent event : events) { + publisher.publishEvent(event); + } + log.info("비동기 알림 테스트 종료. Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName()); + } +} diff --git a/backend/pium/src/main/java/com/official/pium/admin/ui/AdminPageController.java b/backend/pium/src/main/java/com/official/pium/admin/ui/AdminPageController.java index 876797d5..1387f91c 100644 --- a/backend/pium/src/main/java/com/official/pium/admin/ui/AdminPageController.java +++ b/backend/pium/src/main/java/com/official/pium/admin/ui/AdminPageController.java @@ -11,7 +11,6 @@ import com.official.pium.member.domain.Member; import com.official.pium.member.repository.MemberRepository; import com.official.pium.notification.application.NotificationService; -import com.official.pium.petPlant.application.ReminderService; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpSession; import jakarta.validation.Valid; @@ -44,7 +43,6 @@ public class AdminPageController { private final MemberRepository memberRepository; private final AdminService adminService; private final NotificationService notificationService; - private final ReminderService reminderService; @GetMapping("/**") public String adminPage(@AdminAuth Admin admin, Model model) { @@ -164,10 +162,4 @@ public ResponseEntity logout(HttpServletRequest request) { return ResponseEntity.ok().build(); } - - @GetMapping("/notifications") - public ResponseEntity notificationTest() { - reminderService.sendWaterNotificationTest(); - return ResponseEntity.ok("알림 기능 테스트 성공"); - } } 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 new file mode 100644 index 00000000..8b9c4b74 --- /dev/null +++ b/backend/pium/src/main/java/com/official/pium/admin/ui/TestController.java @@ -0,0 +1,34 @@ +package com.official.pium.admin.ui; + +import com.official.pium.admin.service.TestService; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/test") +public class TestController { + + /** + * 1. 모든 알림 이벤트를 단일 스레드로 처리하는 API 2. 모든 알림 이벤트를 각각의 스레드로 처리하는 API + * + * @return + */ + + private final TestService testService; + + @GetMapping("/notifications") + public ResponseEntity notificationTest() { + testService.sendWaterNotificationTest(); + return ResponseEntity.ok("알림 기능 테스트 성공"); + } + + @GetMapping("/notifications/async") + public ResponseEntity notificationAsyncTest() { + testService.sendWaterNotificationAsyncTest(); + return ResponseEntity.ok("비동기 알림 기능 테스트 성공"); + } +} diff --git a/backend/pium/src/main/java/com/official/pium/notification/application/NotificationEventListener.java b/backend/pium/src/main/java/com/official/pium/notification/application/NotificationEventListener.java index be0af1ef..906b1b96 100644 --- a/backend/pium/src/main/java/com/official/pium/notification/application/NotificationEventListener.java +++ b/backend/pium/src/main/java/com/official/pium/notification/application/NotificationEventListener.java @@ -3,12 +3,14 @@ import com.official.pium.petPlant.event.notification.NotificationEvent; import com.official.pium.petPlant.event.notification.NotificationEvents; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.context.event.EventListener; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; @Component @RequiredArgsConstructor +@Slf4j public class NotificationEventListener { private final NotificationService notificationService; @@ -16,8 +18,18 @@ public class NotificationEventListener { @EventListener @Async public void handleNotificationEvents(NotificationEvents notificationEvents) { + log.info("동기 알림 START, Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName()); for (NotificationEvent event : notificationEvents.getNotificationEvents()) { notificationService.sendNotification(event.getDeviceToken(), event.getTitle(), event.getBody()); } + log.info("동기 알림 END, Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName()); + } + + @EventListener + @Async + public void handleNotificationEvent(NotificationEvent event) { + log.info("비동기 알림 START, Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName()); + notificationService.sendNotification(event.getDeviceToken(), event.getTitle(), event.getBody()); + log.info("비동기 알림 END, Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName()); } } diff --git a/backend/pium/src/main/java/com/official/pium/petPlant/application/ReminderService.java b/backend/pium/src/main/java/com/official/pium/petPlant/application/ReminderService.java index 6ec8a821..cd5420f1 100644 --- a/backend/pium/src/main/java/com/official/pium/petPlant/application/ReminderService.java +++ b/backend/pium/src/main/java/com/official/pium/petPlant/application/ReminderService.java @@ -91,17 +91,4 @@ public void sendWaterNotification() { publisher.publishEvent(NotificationEvents.from(events)); } - - public void sendWaterNotificationTest() { - List petPlants = petPlantRepository.findAll(); - List events = petPlants.stream() - .map(plant -> NotificationEvent.builder() - .title(plant.getNickname()) - .body("(테스트 중) 물을 줄 시간이에요!") - .deviceToken(plant.getMember().getDeviceToken()) - .build() - ).toList(); - - publisher.publishEvent(NotificationEvents.from(events)); - } } diff --git a/backend/pium/src/test/java/com/official/pium/admin/controller/AdminPageControllerTest.java b/backend/pium/src/test/java/com/official/pium/admin/controller/AdminPageControllerTest.java index 67ec8329..cbb6a017 100644 --- a/backend/pium/src/test/java/com/official/pium/admin/controller/AdminPageControllerTest.java +++ b/backend/pium/src/test/java/com/official/pium/admin/controller/AdminPageControllerTest.java @@ -26,7 +26,6 @@ import com.official.pium.fixture.MemberFixture; import com.official.pium.fixture.NotificationFixture; import com.official.pium.notification.application.NotificationService; -import com.official.pium.petPlant.application.ReminderService; import java.util.List; import java.util.Optional; import org.junit.jupiter.api.DisplayNameGeneration; @@ -65,9 +64,6 @@ class AdminPageControllerTest extends UITest { @MockBean private NotificationService notificationService; - @MockBean - private ReminderService reminderService; - @Nested class 페이지_정상_호출_ { From bea9ea6ee6333114149d9fbc993f669f4d56a58b Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Sat, 6 Jan 2024 17:58:40 +0900 Subject: [PATCH 02/45] =?UTF-8?q?test:=20@EnableAsync=20=EC=96=B4=EB=85=B8?= =?UTF-8?q?=ED=85=8C=EC=9D=B4=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pium/src/main/java/com/official/pium/PiumApplication.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/pium/src/main/java/com/official/pium/PiumApplication.java b/backend/pium/src/main/java/com/official/pium/PiumApplication.java index 770f87db..f51ff858 100644 --- a/backend/pium/src/main/java/com/official/pium/PiumApplication.java +++ b/backend/pium/src/main/java/com/official/pium/PiumApplication.java @@ -2,8 +2,10 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.scheduling.annotation.EnableAsync; @SpringBootApplication +@EnableAsync public class PiumApplication { public static void main(String[] args) { From ffe1549a629eb6993b49a097e4b44192c25f5ca3 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Sat, 6 Jan 2024 19:39:16 +0900 Subject: [PATCH 03/45] =?UTF-8?q?test:=20=EC=95=8C=EB=A6=BC=20=EC=9D=B4?= =?UTF-8?q?=EB=B2=A4=ED=8A=B8=20=EB=A1=9C=EA=B7=B8=20=EC=A0=95=EB=B3=B4=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/official/pium/admin/service/TestService.java | 2 ++ 1 file changed, 2 insertions(+) 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 0cb6e6fb..ecd88939 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 @@ -44,8 +44,10 @@ public void sendWaterNotificationAsyncTest() { .build() ).toList(); + int i = 1; log.info("비동기 알림 테스트 시작. Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName()); for (NotificationEvent event : events) { + log.info(i++ + "번째 알림 이벤트"); publisher.publishEvent(event); } log.info("비동기 알림 테스트 종료. Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName()); From 4a5082fcabd6c8a68c261ff02cb281b06168de82 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Sat, 6 Jan 2024 21:39:31 +0900 Subject: [PATCH 04/45] =?UTF-8?q?test:=20=EB=AF=B8=EC=82=AC=EC=9A=A9=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20api=20=EC=A3=BC=EC=84=9D=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pium/admin/service/TestService.java | 27 +++++++++---------- .../pium/admin/ui/TestController.java | 10 +++---- 2 files changed, 18 insertions(+), 19 deletions(-) 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 ecd88939..0f4228e4 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 @@ -2,7 +2,6 @@ import com.official.pium.petPlant.domain.PetPlant; import com.official.pium.petPlant.event.notification.NotificationEvent; -import com.official.pium.petPlant.event.notification.NotificationEvents; import com.official.pium.petPlant.repository.PetPlantRepository; import java.util.List; import lombok.RequiredArgsConstructor; @@ -20,19 +19,19 @@ public class TestService { private final PetPlantRepository petPlantRepository; private final ApplicationEventPublisher publisher; - public void sendWaterNotificationTest() { - 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("동기 알림 테스트 시작. Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName()); - publisher.publishEvent(NotificationEvents.from(events)); - log.info("동기 알림 테스트 종료. Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName()); - } +// public void sendWaterNotificationTest() { +// 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("동기 알림 테스트 시작. Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName()); +// publisher.publishEvent(NotificationEvents.from(events)); +// log.info("동기 알림 테스트 종료. Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName()); +// } public void sendWaterNotificationAsyncTest() { List petPlants = petPlantRepository.findAllByMemberId(7L); 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 8b9c4b74..c2fae203 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 @@ -20,11 +20,11 @@ public class TestController { private final TestService testService; - @GetMapping("/notifications") - public ResponseEntity notificationTest() { - testService.sendWaterNotificationTest(); - return ResponseEntity.ok("알림 기능 테스트 성공"); - } +// @GetMapping("/notifications") +// public ResponseEntity notificationTest() { +// testService.sendWaterNotificationTest(); +// return ResponseEntity.ok("알림 기능 테스트 성공"); +// } @GetMapping("/notifications/async") public ResponseEntity notificationAsyncTest() { From a22ec60c2c87aeefdd406391e48189bbea2ea0c4 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Tue, 9 Jan 2024 21:31:24 +0900 Subject: [PATCH 05/45] =?UTF-8?q?refactor:=20Async=20ThreadExecutor=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/official/pium/PiumApplication.java | 3 +-- .../com/official/pium/config/AsyncConfig.java | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 backend/pium/src/main/java/com/official/pium/config/AsyncConfig.java diff --git a/backend/pium/src/main/java/com/official/pium/PiumApplication.java b/backend/pium/src/main/java/com/official/pium/PiumApplication.java index f51ff858..383db7a8 100644 --- a/backend/pium/src/main/java/com/official/pium/PiumApplication.java +++ b/backend/pium/src/main/java/com/official/pium/PiumApplication.java @@ -2,10 +2,9 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.scheduling.annotation.EnableAsync; @SpringBootApplication -@EnableAsync +//@EnableAsync public class PiumApplication { public static void main(String[] args) { 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 new file mode 100644 index 00000000..916aaaf7 --- /dev/null +++ b/backend/pium/src/main/java/com/official/pium/config/AsyncConfig.java @@ -0,0 +1,23 @@ +package com.official.pium.config; + +import java.util.concurrent.Executor; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.AsyncConfigurer; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; + +@Configuration +@EnableAsync +public class AsyncConfig implements AsyncConfigurer { + + @Override + public Executor getAsyncExecutor() { + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setCorePoolSize(20); + executor.setQueueCapacity(10); + executor.setMaxPoolSize(200); + executor.setThreadNamePrefix("2024-Pium"); + executor.initialize(); + return executor; + } +} From 47dc1332c72304b7fdc83a3b29e15fd28ee3c334 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Tue, 9 Jan 2024 21:49:09 +0900 Subject: [PATCH 06/45] =?UTF-8?q?refactor:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=ED=8A=B8=EB=9E=9C=EC=9E=AD=EC=85=98=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pium/notification/application/NotificationService.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/backend/pium/src/main/java/com/official/pium/notification/application/NotificationService.java b/backend/pium/src/main/java/com/official/pium/notification/application/NotificationService.java index 753aa09c..dca360f8 100644 --- a/backend/pium/src/main/java/com/official/pium/notification/application/NotificationService.java +++ b/backend/pium/src/main/java/com/official/pium/notification/application/NotificationService.java @@ -2,10 +2,8 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; @Service -@Transactional(readOnly = true) @RequiredArgsConstructor public class NotificationService { From 68644dfcf61bf9fdbc324f38aea84c758acb3571 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Tue, 9 Jan 2024 22:05:57 +0900 Subject: [PATCH 07/45] =?UTF-8?q?refactor:=20Async=20ThreadPool=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/official/pium/config/AsyncConfig.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 916aaaf7..52810b3e 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 @@ -14,9 +14,9 @@ public class AsyncConfig implements AsyncConfigurer { public Executor getAsyncExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); executor.setCorePoolSize(20); - executor.setQueueCapacity(10); - executor.setMaxPoolSize(200); - executor.setThreadNamePrefix("2024-Pium"); +// executor.setQueueCapacity(15); +// executor.setMaxPoolSize(200); + executor.setThreadNamePrefix("2024-Pium-Thread: "); executor.initialize(); return executor; } From c6d8f44f861bc117a63b7b3c96c2fe384616fd29 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Wed, 10 Jan 2024 15:01:42 +0900 Subject: [PATCH 08/45] =?UTF-8?q?refactor:=20Async=20ThreadPool=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=2030=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/official/pium/config/AsyncConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: "); From 8472a4a18f424be51315675a9b7cef6a78c033b3 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Wed, 10 Jan 2024 15:34:22 +0900 Subject: [PATCH 09/45] =?UTF-8?q?refactor:=20Async=20ThreadPool=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=2020=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/official/pium/config/AsyncConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 14dc77a2..52810b3e 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(30); + executor.setCorePoolSize(20); // executor.setQueueCapacity(15); // executor.setMaxPoolSize(200); executor.setThreadNamePrefix("2024-Pium-Thread: "); From cdcb3c2c751181112bd01086d45cea555ac1fb19 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Wed, 10 Jan 2024 15:45:40 +0900 Subject: [PATCH 10/45] =?UTF-8?q?refactor:=20Async=20ThreadPool=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=2040=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/official/pium/config/AsyncConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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..fffde222 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(40); // executor.setQueueCapacity(15); // executor.setMaxPoolSize(200); executor.setThreadNamePrefix("2024-Pium-Thread: "); From 0b3b9c8d0ccbf2a3e1296a3a50a47f63efa102cd Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Wed, 10 Jan 2024 15:55:36 +0900 Subject: [PATCH 11/45] =?UTF-8?q?refactor:=20Async=20ThreadPool=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=2020=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/official/pium/config/AsyncConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 fffde222..52810b3e 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(40); + executor.setCorePoolSize(20); // executor.setQueueCapacity(15); // executor.setMaxPoolSize(200); executor.setThreadNamePrefix("2024-Pium-Thread: "); From 9fc3d3d882717e2aec19f3630b58ee66e0548850 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Wed, 10 Jan 2024 16:41:27 +0900 Subject: [PATCH 12/45] =?UTF-8?q?refactor:=20Async=20ThreadPool=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=2030=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pium/admin/service/TestService.java | 17 +++++++++++++++++ .../official/pium/admin/ui/TestController.java | 6 ++++++ .../com/official/pium/config/AsyncConfig.java | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) 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: "); From 6478813291e9f69837cef6ad1a8e67d52c596c0b Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Wed, 10 Jan 2024 16:54:26 +0900 Subject: [PATCH 13/45] =?UTF-8?q?refactor:=20Async=20ThreadPool=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=2040=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/official/pium/config/AsyncConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 14dc77a2..fffde222 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(30); + executor.setCorePoolSize(40); // executor.setQueueCapacity(15); // executor.setMaxPoolSize(200); executor.setThreadNamePrefix("2024-Pium-Thread: "); From 8630a2346fa81735e654388a84f1ea4585d99225 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Wed, 10 Jan 2024 17:11:43 +0900 Subject: [PATCH 14/45] =?UTF-8?q?refactor:=20Async=20ThreadPool=20?= =?UTF-8?q?=EB=9E=A8=ED=94=84=EC=97=85=20=EC=8A=A4=EB=A0=88=EB=93=9C=20?= =?UTF-8?q?=EC=88=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/official/pium/admin/service/TestService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 faf30fd6..10b384cd 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 @@ -44,7 +44,7 @@ public void sendWaterNotificationAsyncRampTest() { ).toList(); log.info("비동기 테스트 램프업 시작"); - for (int i = 0; i < 40; i++) { + for (int i = 0; i < 100; i++) { NotificationEvent notificationEvent = events.get(i); publisher.publishEvent(notificationEvent); } From 5604c111c4c7514be40bf3053c2627bcc89071ef Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Thu, 11 Jan 2024 16:04:32 +0900 Subject: [PATCH 15/45] =?UTF-8?q?refactor:=20Async=20ThreadPool=20?= =?UTF-8?q?=EC=8A=A4=EB=A0=88=EB=93=9C=20=EC=88=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/official/pium/config/AsyncConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 fffde222..52810b3e 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(40); + executor.setCorePoolSize(20); // executor.setQueueCapacity(15); // executor.setMaxPoolSize(200); executor.setThreadNamePrefix("2024-Pium-Thread: "); From 9fd865115c27ade7836e459d686e392b5eb98bb1 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Thu, 11 Jan 2024 16:50:41 +0900 Subject: [PATCH 16/45] =?UTF-8?q?refactor:=20Async=20ThreadPool=20?= =?UTF-8?q?=EC=8A=A4=EB=A0=88=EB=93=9C=20=EC=88=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/official/pium/config/AsyncConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: "); From b615b8b375edd1fa7b184b4b777efd8e0415f40d Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Thu, 11 Jan 2024 17:22:40 +0900 Subject: [PATCH 17/45] =?UTF-8?q?refactor:=20Async=20ThreadPool=20?= =?UTF-8?q?=EC=8A=A4=EB=A0=88=EB=93=9C=20=EC=88=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/official/pium/config/AsyncConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 14dc77a2..3b0c5f1d 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(30); + executor.setCorePoolSize(50); // executor.setQueueCapacity(15); // executor.setMaxPoolSize(200); executor.setThreadNamePrefix("2024-Pium-Thread: "); From 597f09a4a4b20a73109479384f2a7453ecbaf4bf Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Thu, 11 Jan 2024 17:49:08 +0900 Subject: [PATCH 18/45] =?UTF-8?q?refactor:=20Async=20ThreadPool=20?= =?UTF-8?q?=EC=8A=A4=EB=A0=88=EB=93=9C=20=EC=88=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/official/pium/config/AsyncConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 3b0c5f1d..fffde222 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(50); + executor.setCorePoolSize(40); // executor.setQueueCapacity(15); // executor.setMaxPoolSize(200); executor.setThreadNamePrefix("2024-Pium-Thread: "); From 3db6b51c127b65dbca96c2b6c569935be563a82e Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Thu, 11 Jan 2024 19:19:44 +0900 Subject: [PATCH 19/45] =?UTF-8?q?refactor:=20Async=20ThreadPool=20?= =?UTF-8?q?=EC=8A=A4=EB=A0=88=EB=93=9C=20=EC=88=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/official/pium/config/AsyncConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 fffde222..52810b3e 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(40); + executor.setCorePoolSize(20); // executor.setQueueCapacity(15); // executor.setMaxPoolSize(200); executor.setThreadNamePrefix("2024-Pium-Thread: "); From e28bad09a1d84f3f0f1e84e8262d8fd01b1f2ac7 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Thu, 11 Jan 2024 19:39:36 +0900 Subject: [PATCH 20/45] =?UTF-8?q?refactor:=20Async=20ThreadPool=20?= =?UTF-8?q?=EC=8A=A4=EB=A0=88=EB=93=9C=20=EC=88=98=2030=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/official/pium/config/AsyncConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: "); From 89435a4f0f13e56621100a2f743b1544c4c3e982 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Thu, 11 Jan 2024 19:53:20 +0900 Subject: [PATCH 21/45] =?UTF-8?q?refactor:=20Async=20ThreadPool=20?= =?UTF-8?q?=EC=8A=A4=EB=A0=88=EB=93=9C=20=EC=88=98=2050=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/official/pium/config/AsyncConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 14dc77a2..3b0c5f1d 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(30); + executor.setCorePoolSize(50); // executor.setQueueCapacity(15); // executor.setMaxPoolSize(200); executor.setThreadNamePrefix("2024-Pium-Thread: "); From 95cc8e6f2e4a753564adb1ff201ad4edcfb0e7b8 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Thu, 11 Jan 2024 20:57:16 +0900 Subject: [PATCH 22/45] =?UTF-8?q?refactor:=20Async=20ThreadPool=20?= =?UTF-8?q?=EC=8A=A4=EB=A0=88=EB=93=9C=20=EC=88=98=2040=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/official/pium/config/AsyncConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 3b0c5f1d..fffde222 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(50); + executor.setCorePoolSize(40); // executor.setQueueCapacity(15); // executor.setMaxPoolSize(200); executor.setThreadNamePrefix("2024-Pium-Thread: "); From 659ca56710b05846f2a4e9ba8c202b4da44d68e8 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Thu, 11 Jan 2024 21:15:46 +0900 Subject: [PATCH 23/45] =?UTF-8?q?refactor:=20Async=20ThreadPool=20?= =?UTF-8?q?=EC=8A=A4=EB=A0=88=EB=93=9C=20=EC=88=98=2030=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/official/pium/config/AsyncConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 fffde222..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(40); + executor.setCorePoolSize(30); // executor.setQueueCapacity(15); // executor.setMaxPoolSize(200); executor.setThreadNamePrefix("2024-Pium-Thread: "); From 1a13090bfdad57b79cfa78f698dbf1ab5a20e1ab Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Thu, 11 Jan 2024 21:39:22 +0900 Subject: [PATCH 24/45] =?UTF-8?q?refactor:=20Async=20ThreadPool=20?= =?UTF-8?q?=EC=8A=A4=EB=A0=88=EB=93=9C=20=EC=88=98=20100=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/official/pium/config/AsyncConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 14dc77a2..e4a80369 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(30); + executor.setCorePoolSize(100); // executor.setQueueCapacity(15); // executor.setMaxPoolSize(200); executor.setThreadNamePrefix("2024-Pium-Thread: "); From eb10b0cdc5a653049b0cfc52ff595adceb0c605d Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Tue, 16 Jan 2024 16:12:37 +0900 Subject: [PATCH 25/45] =?UTF-8?q?refactor:=20Async=20ThreadPool=20?= =?UTF-8?q?=EC=8A=A4=EB=A0=88=EB=93=9C=20=EC=88=98=208=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/official/pium/config/AsyncConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e4a80369..60ded3bb 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(100); + executor.setCorePoolSize(8); // executor.setQueueCapacity(15); // executor.setMaxPoolSize(200); executor.setThreadNamePrefix("2024-Pium-Thread: "); From 33d1c88574bbd550e4beb3c67144d846ac6894f6 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Tue, 16 Jan 2024 18:16:50 +0900 Subject: [PATCH 26/45] =?UTF-8?q?refactor:=20Async=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=84=A4=EC=A0=95=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/official/pium/admin/service/TestService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 10b384cd..617a807a 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 @@ -34,7 +34,7 @@ public class TestService { // } public void sendWaterNotificationAsyncRampTest() { - List petPlants = petPlantRepository.findAllByMemberId(7L); + List petPlants = petPlantRepository.findAllByMemberId(6L); List events = petPlants.stream() .map(plant -> NotificationEvent.builder() .title(plant.getNickname()) @@ -51,7 +51,7 @@ public void sendWaterNotificationAsyncRampTest() { } public void sendWaterNotificationAsyncTest() { - List petPlants = petPlantRepository.findAllByMemberId(7L); + List petPlants = petPlantRepository.findAllByMemberId(6L); List events = petPlants.stream() .map(plant -> NotificationEvent.builder() .title(plant.getNickname()) From 9544240b9766b65f32ef47f802d61023b5cf69e3 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Tue, 16 Jan 2024 18:46:12 +0900 Subject: [PATCH 27/45] =?UTF-8?q?refactor:=20Async=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=8A=A4=EB=A0=88=EB=93=9C=20=ED=92=80=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=2015=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/official/pium/config/AsyncConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 60ded3bb..7ca74f6c 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(8); + executor.setCorePoolSize(15); // executor.setQueueCapacity(15); // executor.setMaxPoolSize(200); executor.setThreadNamePrefix("2024-Pium-Thread: "); From 81d17c346d21b59bec2a26f23d1fa0a58c593fa4 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Tue, 16 Jan 2024 19:08:12 +0900 Subject: [PATCH 28/45] =?UTF-8?q?refactor:=20Async=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=8A=A4=EB=A0=88=EB=93=9C=20=ED=92=80=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=2015=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/official/pium/config/AsyncConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 7ca74f6c..52810b3e 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(15); + executor.setCorePoolSize(20); // executor.setQueueCapacity(15); // executor.setMaxPoolSize(200); executor.setThreadNamePrefix("2024-Pium-Thread: "); From e437712cf153791b2a1d36c28392fc06fa053488 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Tue, 16 Jan 2024 19:43:58 +0900 Subject: [PATCH 29/45] =?UTF-8?q?refactor:=20Async=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=8A=A4=EB=A0=88=EB=93=9C=20=ED=92=80=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=2025=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/official/pium/config/AsyncConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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..9aa38761 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(25); // executor.setQueueCapacity(15); // executor.setMaxPoolSize(200); executor.setThreadNamePrefix("2024-Pium-Thread: "); From 63422eb3f599d860abd86dee04513eae86fcb5be Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Tue, 16 Jan 2024 20:38:49 +0900 Subject: [PATCH 30/45] =?UTF-8?q?refactor:=20=EB=9E=A8=ED=94=84=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EB=B0=98=EB=B3=B5=20=ED=9A=9F=EC=88=98=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pium/admin/service/TestService.java | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) 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 617a807a..b12cba39 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 @@ -35,19 +35,29 @@ public class TestService { public void sendWaterNotificationAsyncRampTest() { List petPlants = petPlantRepository.findAllByMemberId(6L); - List events = petPlants.stream() - .map(plant -> NotificationEvent.builder() - .title(plant.getNickname()) - .body("(테스트 중) 물을 줄 시간이에요!") - .deviceToken(plant.getMember().getDeviceToken()) - .build() - ).toList(); +// 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 < 100; i++) { - NotificationEvent notificationEvent = events.get(i); - publisher.publishEvent(notificationEvent); + PetPlant petPlant = petPlants.get(i); + NotificationEvent event = NotificationEvent.builder() + .title(petPlant.getNickname()) + .body("물줘") + .deviceToken(petPlant.getMember().getDeviceToken()) + .build(); + publisher.publishEvent(event); } + +// log.info("비동기 테스트 램프업 시작"); +// for (int i = 0; i < 100; i++) { +// NotificationEvent notificationEvent = events.get(i); +// publisher.publishEvent(notificationEvent); +// } } public void sendWaterNotificationAsyncTest() { From 837d2e1f53b4396cfca78763a21eb6bea694270d Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Wed, 17 Jan 2024 15:08:19 +0900 Subject: [PATCH 31/45] =?UTF-8?q?refactor:=20=EC=95=8C=EB=A6=BC=20?= =?UTF-8?q?=ED=97=88=EC=9A=A9=20=EC=8B=9C=20=EC=95=8C=EB=A6=BC=20=EB=B0=9C?= =?UTF-8?q?=EC=86=A1=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/application/MemberService.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/backend/pium/src/main/java/com/official/pium/member/application/MemberService.java b/backend/pium/src/main/java/com/official/pium/member/application/MemberService.java index 30a39e24..272d3c6c 100644 --- a/backend/pium/src/main/java/com/official/pium/member/application/MemberService.java +++ b/backend/pium/src/main/java/com/official/pium/member/application/MemberService.java @@ -1,16 +1,18 @@ package com.official.pium.member.application; -import com.official.pium.member.domain.Member; -import com.official.pium.petPlant.domain.PetPlant; import com.official.pium.history.repository.HistoryRepository; +import com.official.pium.member.application.dto.OAuthProvider; +import com.official.pium.member.domain.Member; import com.official.pium.member.repository.MemberRepository; -import com.official.pium.petPlant.repository.PetPlantRepository; -import com.official.pium.sessionGroup.repository.SessionGroupRepository; import com.official.pium.notification.application.dto.NotificationCheckResponse; import com.official.pium.notification.application.dto.NotificationSubscribeRequest; -import com.official.pium.member.application.dto.OAuthProvider; +import com.official.pium.petPlant.domain.PetPlant; +import com.official.pium.petPlant.event.notification.NotificationEvent; +import com.official.pium.petPlant.repository.PetPlantRepository; +import com.official.pium.sessionGroup.repository.SessionGroupRepository; import java.util.List; import lombok.RequiredArgsConstructor; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -24,6 +26,7 @@ public class MemberService { private final PetPlantRepository petPlantRepository; private final SessionGroupRepository sessionGroupRepository; private final OAuthProvider provider; + private final ApplicationEventPublisher publisher; @Transactional public void withdraw(Member member) { @@ -51,6 +54,12 @@ public void subscribeNotification(Member member, NotificationSubscribeRequest re throw new IllegalArgumentException("이미 알림을 구독하고 있습니다."); } member.updateDeviceToken(request.getToken()); + NotificationEvent event = NotificationEvent.builder() + .deviceToken(member.getDeviceToken()) + .title("알림 설정 완료") + .body("리마인더 알림 받기 성공.") + .build(); + publisher.publishEvent(event); } @Transactional From f2a1e6e63bf7393b9e32ee7c29a0b8042e7021b2 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Wed, 17 Jan 2024 16:32:31 +0900 Subject: [PATCH 32/45] =?UTF-8?q?refactor:=20Async=20thread=2030=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/official/pium/config/AsyncConfig.java | 2 +- .../official/pium/member/application/MemberService.java | 6 +++++- .../com/official/pium/member/ui/MemberController.java | 8 +++++--- 3 files changed, 11 insertions(+), 5 deletions(-) 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 9aa38761..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(25); + executor.setCorePoolSize(30); // executor.setQueueCapacity(15); // executor.setMaxPoolSize(200); executor.setThreadNamePrefix("2024-Pium-Thread: "); diff --git a/backend/pium/src/main/java/com/official/pium/member/application/MemberService.java b/backend/pium/src/main/java/com/official/pium/member/application/MemberService.java index 272d3c6c..673f3dbb 100644 --- a/backend/pium/src/main/java/com/official/pium/member/application/MemberService.java +++ b/backend/pium/src/main/java/com/official/pium/member/application/MemberService.java @@ -54,10 +54,14 @@ public void subscribeNotification(Member member, NotificationSubscribeRequest re throw new IllegalArgumentException("이미 알림을 구독하고 있습니다."); } member.updateDeviceToken(request.getToken()); + sendAlarmNotification(member); + } + + private void sendAlarmNotification(Member member) { NotificationEvent event = NotificationEvent.builder() .deviceToken(member.getDeviceToken()) .title("알림 설정 완료") - .body("리마인더 알림 받기 성공.") + .body("리마인더 알림 받기 성공") .build(); publisher.publishEvent(event); } diff --git a/backend/pium/src/main/java/com/official/pium/member/ui/MemberController.java b/backend/pium/src/main/java/com/official/pium/member/ui/MemberController.java index f2c23c58..28ca4d72 100644 --- a/backend/pium/src/main/java/com/official/pium/member/ui/MemberController.java +++ b/backend/pium/src/main/java/com/official/pium/member/ui/MemberController.java @@ -1,7 +1,7 @@ package com.official.pium.member.ui; -import com.official.pium.member.domain.Member; import com.official.pium.member.application.MemberService; +import com.official.pium.member.domain.Member; import com.official.pium.notification.application.dto.NotificationCheckResponse; import com.official.pium.notification.application.dto.NotificationSubscribeRequest; import jakarta.servlet.http.HttpServletRequest; @@ -42,8 +42,10 @@ public ResponseEntity checkNotificationStatus(@Auth M } @PostMapping("/notification") - public ResponseEntity subscribeNotification(@Auth Member member, - @RequestBody @Valid NotificationSubscribeRequest request) { + public ResponseEntity subscribeNotification( + @Auth Member member, + @RequestBody @Valid NotificationSubscribeRequest request + ) { memberService.subscribeNotification(member, request); return ResponseEntity.ok().build(); } From 7def1fb79d6de96e9de7fac970d716cf80e8b518 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Wed, 17 Jan 2024 17:13:54 +0900 Subject: [PATCH 33/45] =?UTF-8?q?refactor:=20Async=20thread=2035=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/official/pium/config/AsyncConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 14dc77a2..6e91d674 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(30); + executor.setCorePoolSize(35); // executor.setQueueCapacity(15); // executor.setMaxPoolSize(200); executor.setThreadNamePrefix("2024-Pium-Thread: "); From 0db65533858fd160e0bd496b41e4392bb97b131f Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Wed, 17 Jan 2024 17:46:16 +0900 Subject: [PATCH 34/45] =?UTF-8?q?refactor:=20Async=20thread=2045=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/official/pium/config/AsyncConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6e91d674..fffde222 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(35); + executor.setCorePoolSize(40); // executor.setQueueCapacity(15); // executor.setMaxPoolSize(200); executor.setThreadNamePrefix("2024-Pium-Thread: "); From c5e2efe25094614d4545984ab9ba711b33a65ca8 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Wed, 17 Jan 2024 18:03:00 +0900 Subject: [PATCH 35/45] =?UTF-8?q?refactor:=20Async=20thread=2050=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/official/pium/config/AsyncConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 fffde222..3b0c5f1d 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(40); + executor.setCorePoolSize(50); // executor.setQueueCapacity(15); // executor.setMaxPoolSize(200); executor.setThreadNamePrefix("2024-Pium-Thread: "); From 75d17e28b743be63273ad6cf2a5cfeccfa55a2ff Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Wed, 17 Jan 2024 21:27:37 +0900 Subject: [PATCH 36/45] =?UTF-8?q?refactor:=20Async=20thread=2040=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/official/pium/config/AsyncConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 3b0c5f1d..fffde222 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(50); + executor.setCorePoolSize(40); // executor.setQueueCapacity(15); // executor.setMaxPoolSize(200); executor.setThreadNamePrefix("2024-Pium-Thread: "); From 01c06a89dc2d0ac4402d01cd113059f28fb772b4 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Wed, 17 Jan 2024 21:51:29 +0900 Subject: [PATCH 37/45] =?UTF-8?q?refactor:=20Async=20thread=2050=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/official/pium/config/AsyncConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 fffde222..3b0c5f1d 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(40); + executor.setCorePoolSize(50); // executor.setQueueCapacity(15); // executor.setMaxPoolSize(200); executor.setThreadNamePrefix("2024-Pium-Thread: "); From fcd29a36e6c02be20f41939e721700f2e3e93d50 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Thu, 18 Jan 2024 14:12:35 +0900 Subject: [PATCH 38/45] =?UTF-8?q?test:=20=EC=95=8C=EB=A6=BC=20=EA=B5=AC?= =?UTF-8?q?=EB=8F=85=20=EC=8B=9C=20=EC=95=8C=EB=A6=BC=20=EB=B0=9C=EC=86=A1?= =?UTF-8?q?=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/application/MemberServiceTest.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/backend/pium/src/test/java/com/official/pium/member/application/MemberServiceTest.java b/backend/pium/src/test/java/com/official/pium/member/application/MemberServiceTest.java index 8296e5d4..41c8af20 100644 --- a/backend/pium/src/test/java/com/official/pium/member/application/MemberServiceTest.java +++ b/backend/pium/src/test/java/com/official/pium/member/application/MemberServiceTest.java @@ -8,6 +8,7 @@ import com.official.pium.member.repository.MemberRepository; import com.official.pium.notification.application.dto.NotificationCheckResponse; import com.official.pium.notification.application.dto.NotificationSubscribeRequest; +import com.official.pium.petPlant.event.notification.NotificationEvent; import com.official.pium.petPlant.repository.PetPlantRepository; import com.official.pium.support.MemberSupport; import com.official.pium.support.PetPlantSupport; @@ -20,10 +21,13 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.test.context.event.ApplicationEvents; +import org.springframework.test.context.event.RecordApplicationEvents; @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) @SuppressWarnings("NonAsciiCharacters") @ExtendWith(DatabaseClearExtension.class) +@RecordApplicationEvents @SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT) class MemberServiceTest { @@ -42,6 +46,9 @@ class MemberServiceTest { @Autowired private PetPlantRepository petPlantRepository; + @Autowired + private ApplicationEvents applicationEvents; + @Test void 회원탈퇴_성공() { Member member = Member.builder() @@ -88,6 +95,20 @@ class MemberServiceTest { assertThat(saveMember.getDeviceToken()).isEqualTo("deviceToken"); } + @Test + void 알림_구독_시_구독_완료_알림이_발송된다() { + Member saveMember = memberSupport.builder() + .kakaoId(123451L) + .build(); + + memberService.subscribeNotification(saveMember, NotificationSubscribeRequest.builder() + .token("deviceToken") + .build()); + long eventCount = applicationEvents.stream(NotificationEvent.class).count(); + + assertThat(eventCount).isEqualTo(1); + } + @Test void 알림_해지_시_사용자의_디바이스_토큰에_값이_존재한다() { Member saveMember = memberSupport.builder() From 2b1b2cfc981bcd4c9b2139f82996d88bcf054ac8 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Thu, 18 Jan 2024 14:12:46 +0900 Subject: [PATCH 39/45] =?UTF-8?q?test:=20=EC=95=8C=EB=A6=BC=20=EC=A0=84?= =?UTF-8?q?=EC=86=A1=20=EB=A9=94=EC=84=9C=EB=93=9C=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/NotificationServiceTest.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 backend/pium/src/test/java/com/official/pium/notification/application/NotificationServiceTest.java diff --git a/backend/pium/src/test/java/com/official/pium/notification/application/NotificationServiceTest.java b/backend/pium/src/test/java/com/official/pium/notification/application/NotificationServiceTest.java new file mode 100644 index 00000000..70d7c38c --- /dev/null +++ b/backend/pium/src/test/java/com/official/pium/notification/application/NotificationServiceTest.java @@ -0,0 +1,37 @@ +package com.official.pium.notification.application; + +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import java.util.UUID; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +@SuppressWarnings("NonAsciiCharacters") +@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) +@ExtendWith(MockitoExtension.class) +class NotificationServiceTest { + + @InjectMocks + private NotificationService notificationService; + + @Mock + private MessageSendManager messageSendManager; + + @Test + void 알림_전송_메서드가_알림_발송_메서드를_호출한다() { + String deviceToken = UUID.randomUUID().toString(); + String title = "피움 물주기 알림"; + String body = "오늘은 피우미 물 주는 날"; + + notificationService.sendNotification(deviceToken, title, body); + + verify(messageSendManager, times(1)) + .sendMessageTo(deviceToken, title, body); + } +} From d2defe0fcdd9408e80c1223c8b69c5a518566035 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Thu, 18 Jan 2024 14:40:14 +0900 Subject: [PATCH 40/45] =?UTF-8?q?refactor:=20=EC=95=8C=EB=A6=BC=20?= =?UTF-8?q?=EB=B0=9C=EC=86=A1=20=EB=A1=9C=EC=A7=81=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NotificationEventListener.java | 16 ++++++------- .../petPlant/application/ReminderService.java | 24 +++++++++++-------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/backend/pium/src/main/java/com/official/pium/notification/application/NotificationEventListener.java b/backend/pium/src/main/java/com/official/pium/notification/application/NotificationEventListener.java index 906b1b96..fb19897d 100644 --- a/backend/pium/src/main/java/com/official/pium/notification/application/NotificationEventListener.java +++ b/backend/pium/src/main/java/com/official/pium/notification/application/NotificationEventListener.java @@ -15,6 +15,14 @@ public class NotificationEventListener { private final NotificationService notificationService; + @EventListener + @Async + public void handleNotificationEvent(NotificationEvent event) { + log.info("비동기 알림 START, Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName()); + notificationService.sendNotification(event.getDeviceToken(), event.getTitle(), event.getBody()); + log.info("비동기 알림 END, Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName()); + } + @EventListener @Async public void handleNotificationEvents(NotificationEvents notificationEvents) { @@ -24,12 +32,4 @@ public void handleNotificationEvents(NotificationEvents notificationEvents) { } log.info("동기 알림 END, Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName()); } - - @EventListener - @Async - public void handleNotificationEvent(NotificationEvent event) { - log.info("비동기 알림 START, Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName()); - notificationService.sendNotification(event.getDeviceToken(), event.getTitle(), event.getBody()); - log.info("비동기 알림 END, Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName()); - } } diff --git a/backend/pium/src/main/java/com/official/pium/petPlant/application/ReminderService.java b/backend/pium/src/main/java/com/official/pium/petPlant/application/ReminderService.java index cd5420f1..aa3da94a 100644 --- a/backend/pium/src/main/java/com/official/pium/petPlant/application/ReminderService.java +++ b/backend/pium/src/main/java/com/official/pium/petPlant/application/ReminderService.java @@ -9,12 +9,12 @@ import com.official.pium.petPlant.domain.PetPlant; import com.official.pium.petPlant.event.history.HistoryEvent; import com.official.pium.petPlant.event.notification.NotificationEvent; -import com.official.pium.petPlant.event.notification.NotificationEvents; import com.official.pium.petPlant.repository.PetPlantRepository; import java.time.LocalDate; import java.util.List; import java.util.NoSuchElementException; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.context.ApplicationEventPublisher; import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort.Direction; @@ -22,6 +22,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +@Slf4j @Service @Transactional(readOnly = true) @RequiredArgsConstructor @@ -81,14 +82,17 @@ public DataResponse> readAll(Member member) { @Scheduled(cron = "0 0 7 * * *") public void sendWaterNotification() { List petPlants = petPlantRepository.findAllByWaterNotification(LocalDate.now()); - List events = petPlants.stream() - .map(plant -> NotificationEvent.builder() - .title(plant.getNickname()) - .body("물을 줄 시간이에요!") - .deviceToken(plant.getMember().getDeviceToken()) - .build() - ).toList(); - - publisher.publishEvent(NotificationEvents.from(events)); + log.info("[" + LocalDate.now() + " 물주기] " + "전체 알림: " + petPlants.size() + "개"); + petPlants.forEach(this::sendNotification); + + } + + private void sendNotification(PetPlant petPlant) { + NotificationEvent.builder() + .title(petPlant.getNickname()) + .body("물을 줄 시간이에요!") + .deviceToken(petPlant.getMember().getDeviceToken()) + .build(); + publisher.publishEvent(petPlant); } } From 3e8c068a608e505ac3e66234c7c5d3808ab95b18 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Thu, 18 Jan 2024 15:07:48 +0900 Subject: [PATCH 41/45] =?UTF-8?q?test:=20=EC=95=8C=EB=A6=BC=20=EC=9D=B4?= =?UTF-8?q?=EB=B2=A4=ED=8A=B8=20=EB=A6=AC=EC=8A=A4=EB=84=88=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NotificationEventListenerTest.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 backend/pium/src/test/java/com/official/pium/notification/application/NotificationEventListenerTest.java diff --git a/backend/pium/src/test/java/com/official/pium/notification/application/NotificationEventListenerTest.java b/backend/pium/src/test/java/com/official/pium/notification/application/NotificationEventListenerTest.java new file mode 100644 index 00000000..b1a98cf9 --- /dev/null +++ b/backend/pium/src/test/java/com/official/pium/notification/application/NotificationEventListenerTest.java @@ -0,0 +1,38 @@ +package com.official.pium.notification.application; + +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; + +import com.official.pium.IntegrationTest; +import com.official.pium.petPlant.event.notification.NotificationEvent; +import java.util.UUID; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.ApplicationEventPublisher; + +@SuppressWarnings("NonAsciiCharacters") +@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) +class NotificationEventListenerTest extends IntegrationTest { + + @Autowired + private ApplicationEventPublisher eventPublisher; + + @MockBean + private NotificationEventListener notificationEventListener; + + @Test + void 알림_이벤트가_발행되면_알림_이벤트_리스너가_동작한다() { + NotificationEvent event = NotificationEvent.builder() + .deviceToken(UUID.randomUUID().toString()) + .title("알림 이벤트") + .body("발송") + .build(); + + eventPublisher.publishEvent(event); + + verify(notificationEventListener, times(1)).handleNotificationEvent(event); + } +} From 0bee745609c2a5a17632cb8d207629ca1060dbbd Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Mon, 22 Jan 2024 15:28:29 +0900 Subject: [PATCH 42/45] =?UTF-8?q?chore:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=BB=A8=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EB=B9=84=ED=99=9C?= =?UTF-8?q?=EC=84=B1=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pium/admin/ui/TestController.java | 33 +++++++------------ 1 file changed, 12 insertions(+), 21 deletions(-) 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 dedbf872..555d26df 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 @@ -1,9 +1,6 @@ package com.official.pium.admin.ui; -import com.official.pium.admin.service.TestService; import lombok.RequiredArgsConstructor; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -12,13 +9,7 @@ @RequestMapping("/test") public class TestController { - /** - * 1. 모든 알림 이벤트를 단일 스레드로 처리하는 API 2. 모든 알림 이벤트를 각각의 스레드로 처리하는 API - * - * @return - */ - - private final TestService testService; +// private final TestService testService; // @GetMapping("/notifications") // public ResponseEntity notificationTest() { @@ -26,15 +17,15 @@ 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(); - return ResponseEntity.ok("비동기 알림 기능 테스트 성공"); - } +// @GetMapping("/notifications/ramp") +// public ResponseEntity notificationRampTest() { +// testService.sendWaterNotificationAsyncRampTest(); +// return ResponseEntity.ok("비동기 알림 기능 테스트 램프업 성공"); +// } +// +// @GetMapping("/notifications/async") +// public ResponseEntity notificationAsyncTest() { +// testService.sendWaterNotificationAsyncTest(); +// return ResponseEntity.ok("비동기 알림 기능 테스트 성공"); +// } } From 3724a820266db34f9dc0706b01afc8a66119d749 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Mon, 22 Jan 2024 15:34:06 +0900 Subject: [PATCH 43/45] =?UTF-8?q?chore:=20=EB=B9=84=EB=8F=99=EA=B8=B0=20?= =?UTF-8?q?=EC=8A=A4=EB=A0=88=EB=93=9C=20=ED=92=80=20=EC=BD=94=EC=96=B4=20?= =?UTF-8?q?=EC=88=98=2040=EC=9C=BC=EB=A1=9C=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/official/pium/config/AsyncConfig.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) 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 3b0c5f1d..3518b7b7 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,9 +13,7 @@ public class AsyncConfig implements AsyncConfigurer { @Override public Executor getAsyncExecutor() { ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - executor.setCorePoolSize(50); -// executor.setQueueCapacity(15); -// executor.setMaxPoolSize(200); + executor.setCorePoolSize(40); executor.setThreadNamePrefix("2024-Pium-Thread: "); executor.initialize(); return executor; From 9fd8bdf8d42600b1b574febe98da447d9f582b30 Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Mon, 22 Jan 2024 15:38:38 +0900 Subject: [PATCH 44/45] =?UTF-8?q?chore:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EC=A3=BC=EC=84=9D=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pium/src/main/java/com/official/pium/PiumApplication.java | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/pium/src/main/java/com/official/pium/PiumApplication.java b/backend/pium/src/main/java/com/official/pium/PiumApplication.java index 383db7a8..770f87db 100644 --- a/backend/pium/src/main/java/com/official/pium/PiumApplication.java +++ b/backend/pium/src/main/java/com/official/pium/PiumApplication.java @@ -4,7 +4,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication -//@EnableAsync public class PiumApplication { public static void main(String[] args) { From a69624d6a19ec1b08e0cf9d2bed91c871bb46d0e Mon Sep 17 00:00:00 2001 From: DongUk <68818952+Kim0914@users.noreply.github.com> Date: Mon, 22 Jan 2024 16:33:04 +0900 Subject: [PATCH 45/45] =?UTF-8?q?refactor:=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=EB=84=88=20=EB=B0=8F=20=EC=9D=B4=EB=B2=A4?= =?UTF-8?q?=ED=8A=B8=20=EA=B0=9D=EC=B2=B4=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/NotificationEventListener.java | 11 ----------- .../event/notification/NotificationEvents.java | 17 ----------------- 2 files changed, 28 deletions(-) delete mode 100644 backend/pium/src/main/java/com/official/pium/petPlant/event/notification/NotificationEvents.java diff --git a/backend/pium/src/main/java/com/official/pium/notification/application/NotificationEventListener.java b/backend/pium/src/main/java/com/official/pium/notification/application/NotificationEventListener.java index fb19897d..ffbd5c56 100644 --- a/backend/pium/src/main/java/com/official/pium/notification/application/NotificationEventListener.java +++ b/backend/pium/src/main/java/com/official/pium/notification/application/NotificationEventListener.java @@ -1,7 +1,6 @@ package com.official.pium.notification.application; import com.official.pium.petPlant.event.notification.NotificationEvent; -import com.official.pium.petPlant.event.notification.NotificationEvents; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.context.event.EventListener; @@ -22,14 +21,4 @@ public void handleNotificationEvent(NotificationEvent event) { notificationService.sendNotification(event.getDeviceToken(), event.getTitle(), event.getBody()); log.info("비동기 알림 END, Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName()); } - - @EventListener - @Async - public void handleNotificationEvents(NotificationEvents notificationEvents) { - log.info("동기 알림 START, Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName()); - for (NotificationEvent event : notificationEvents.getNotificationEvents()) { - notificationService.sendNotification(event.getDeviceToken(), event.getTitle(), event.getBody()); - } - log.info("동기 알림 END, Thread: " + Thread.currentThread().getId() + " " + Thread.currentThread().getName()); - } } diff --git a/backend/pium/src/main/java/com/official/pium/petPlant/event/notification/NotificationEvents.java b/backend/pium/src/main/java/com/official/pium/petPlant/event/notification/NotificationEvents.java deleted file mode 100644 index b6f556fe..00000000 --- a/backend/pium/src/main/java/com/official/pium/petPlant/event/notification/NotificationEvents.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.official.pium.petPlant.event.notification; - -import java.util.List; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -@Getter -@RequiredArgsConstructor(access = AccessLevel.PRIVATE) -public class NotificationEvents { - - private final List notificationEvents; - - public static NotificationEvents from(List notificationEvents) { - return new NotificationEvents(notificationEvents); - } -}