From 2847cda03c84f5a4ef540f17aa8bed9867d66c14 Mon Sep 17 00:00:00 2001 From: eojin0814 Date: Tue, 14 Nov 2023 09:44:54 +0900 Subject: [PATCH] fix (#1) : scheduled delay of 10 seconds --- .../domain/morpheme/domain/service/NewsAPIService.java | 5 +++++ .../domain/morpheme/presentation/MorphemeController.java | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/gwangjang/server/domain/morpheme/domain/service/NewsAPIService.java b/src/main/java/gwangjang/server/domain/morpheme/domain/service/NewsAPIService.java index 00e06fa..6ec1c24 100644 --- a/src/main/java/gwangjang/server/domain/morpheme/domain/service/NewsAPIService.java +++ b/src/main/java/gwangjang/server/domain/morpheme/domain/service/NewsAPIService.java @@ -86,6 +86,11 @@ public String naverAPI(String name) throws JsonProcessingException { e.printStackTrace(); } } + try { + Thread.sleep(1000); // 100 milliseconds delay + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } return rslt.toString(); } diff --git a/src/main/java/gwangjang/server/domain/morpheme/presentation/MorphemeController.java b/src/main/java/gwangjang/server/domain/morpheme/presentation/MorphemeController.java index 9b4b362..d4cd989 100644 --- a/src/main/java/gwangjang/server/domain/morpheme/presentation/MorphemeController.java +++ b/src/main/java/gwangjang/server/domain/morpheme/presentation/MorphemeController.java @@ -22,7 +22,7 @@ public class MorphemeController { private final NewsAPIService newsAPIService; private final MorphemeService morphemeService; //@GetMapping("/analysis/{msg}") - @Scheduled(cron = "* * * * * 2") + @Scheduled(cron = "* * * * * 2" , fixedDelay = 30000) public String analysis() throws JsonProcessingException { String newsList1 = newsAPIService.naverAPI("주 69시간 근로시간 제도 개편"); String newsList2 = newsAPIService.naverAPI("이태원 참사");