Skip to content

Commit

Permalink
feat(#1) : scheduled cron Log
Browse files Browse the repository at this point in the history
  • Loading branch information
eojinny committed Nov 14, 2023
1 parent 6cab3a7 commit 01f1306
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import io.swagger.annotations.ApiOperation;
import kr.co.shineware.nlp.komoran.model.Token;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -14,41 +16,47 @@
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.logging.Logger;

@RestController
@RequestMapping("/keyword")
@RequiredArgsConstructor
@Log4j
public class MorphemeController {

private static final Logger logger = (Logger) LoggerFactory.getLogger(MorphemeController.class);
private final NewsAPIService newsAPIService;
private final MorphemeService morphemeService;
//@GetMapping("/analysis/{msg}")

@Scheduled(cron = "55 3 * * 2")
//@GetMapping("/test")
//@Scheduled(cron = "55 3 * * 2")
@GetMapping("/test")
public String analysis() throws JsonProcessingException {
logger.info("ASYNC Start");
String newsList1 = newsAPIService.naverAPI("주 69시간 근로시간 제도 개편");
String newsList2 = newsAPIService.naverAPI("이태원 참사");
String newsList3 = newsAPIService.naverAPI("국민연금 개혁");

asyncMethodNews(newsList1);
asyncMethodNews2(newsList2);
asyncMethodNews3(newsList3);
logger.info("End");
return "success";
}
@Async
public void asyncMethodNews(String newsList1) throws JsonProcessingException {
logger.info("ASYNC Start 1");
List<Token> newsAnalysis1 =newsAPIService.analysis(newsList1);
morphemeService.saveOrUpdateWord(newsAnalysis1, 100 );
}
@Async
public void asyncMethodNews2(String newsList2) throws JsonProcessingException {

logger.info("ASYNC Start 2");
List<Token> newsAnalysis2 =newsAPIService.analysis(newsList2);
morphemeService.saveOrUpdateWord(newsAnalysis2, 200);
}
@Async
public void asyncMethodNews3(String newsList3) throws JsonProcessingException {
logger.info("ASYNC Start 3");
List<Token> newsAnalysis3 =newsAPIService.analysis(newsList3);
morphemeService.saveOrUpdateWord(newsAnalysis3, 300);
}
Expand Down

0 comments on commit 01f1306

Please sign in to comment.