강의

멘토링

로드맵

Inflearn Community Q&A

sulum1140's profile image
sulum1140

asked

Spring Core Principles - Advanced

Retry AOP

Retry 애노테이션으로 재시도 실행결과가 좀 이상합니다.

Written on

·

603

0

본문에는 예외가 발생 시 Retry 애노테이션을 확인해서

request를 재시도 하는것으로 나와있는데

 

막상 실행 시켜보면 예외가 발생하지 않아도 

Retry 프록시가 실행되는거 같아서요

 

먼가 잘못이해하고 있는걸까요??

 

실행결과 로그는 아래와 같습니다.

 

 

2022-02-19 12:49:47.587  INFO 18976 --- [           main] hello.aop.exam.ExamTest                  : Started ExamTest in 3.008 seconds (JVM running for 5.288)

2022-02-19 12:49:48.363  INFO 18976 --- [           main] hello.aop.exam.ExamTest                  : client request i = 0

2022-02-19 12:49:48.387  INFO 18976 --- [           main] hello.aop.exam.aop.TraceAspect           : [trace] void hello.aop.exam.ExamService.request(String) args=[data0]

2022-02-19 12:49:48.416  INFO 18976 --- [           main] hello.aop.exam.aop.TraceAspect           : [trace] String hello.aop.exam.ExamRepository.save(String) args=[data0]

2022-02-19 12:49:48.417  INFO 18976 --- [           main] hello.aop.exam.aop.RetryAspect           : [retry] String hello.aop.exam.ExamRepository.save(String) retry=@hello.aop.exam.annotation.Retry(value=4)

2022-02-19 12:49:48.417  INFO 18976 --- [           main] hello.aop.exam.aop.RetryAspect           : [retry] try count=1/4

2022-02-19 12:49:48.428  INFO 18976 --- [           main] hello.aop.exam.ExamTest                  : client request i = 1

2022-02-19 12:49:48.429  INFO 18976 --- [           main] hello.aop.exam.aop.TraceAspect           : [trace] void hello.aop.exam.ExamService.request(String) args=[data1]

2022-02-19 12:49:48.429  INFO 18976 --- [           main] hello.aop.exam.aop.TraceAspect           : [trace] String hello.aop.exam.ExamRepository.save(String) args=[data1]

2022-02-19 12:49:48.430  INFO 18976 --- [           main] hello.aop.exam.aop.RetryAspect           : [retry] String hello.aop.exam.ExamRepository.save(String) retry=@hello.aop.exam.annotation.Retry(value=4)

2022-02-19 12:49:48.430  INFO 18976 --- [           main] hello.aop.exam.aop.RetryAspect           : [retry] try count=1/4

2022-02-19 12:49:48.430  INFO 18976 --- [           main] hello.aop.exam.ExamTest                  : client request i = 2

2022-02-19 12:49:48.430  INFO 18976 --- [           main] hello.aop.exam.aop.TraceAspect           : [trace] void hello.aop.exam.ExamService.request(String) args=[data2]

2022-02-19 12:49:48.430  INFO 18976 --- [           main] hello.aop.exam.aop.TraceAspect           : [trace] String hello.aop.exam.ExamRepository.save(String) args=[data2]

2022-02-19 12:49:48.432  INFO 18976 --- [           main] hello.aop.exam.aop.RetryAspect           : [retry] String hello.aop.exam.ExamRepository.save(String) retry=@hello.aop.exam.annotation.Retry(value=4)

2022-02-19 12:49:48.432  INFO 18976 --- [           main] hello.aop.exam.aop.RetryAspect           : [retry] try count=1/4

2022-02-19 12:49:48.432  INFO 18976 --- [           main] hello.aop.exam.ExamTest                  : client request i = 3

2022-02-19 12:49:48.432  INFO 18976 --- [           main] hello.aop.exam.aop.TraceAspect           : [trace] void hello.aop.exam.ExamService.request(String) args=[data3]

2022-02-19 12:49:48.432  INFO 18976 --- [           main] hello.aop.exam.aop.TraceAspect           : [trace] String hello.aop.exam.ExamRepository.save(String) args=[data3]

2022-02-19 12:49:48.432  INFO 18976 --- [           main] hello.aop.exam.aop.RetryAspect           : [retry] String hello.aop.exam.ExamRepository.save(String) retry=@hello.aop.exam.annotation.Retry(value=4)

2022-02-19 12:49:48.433  INFO 18976 --- [           main] hello.aop.exam.aop.RetryAspect           : [retry] try count=1/4

2022-02-19 12:49:48.433  INFO 18976 --- [           main] hello.aop.exam.ExamTest                  : client request i = 4

2022-02-19 12:49:48.433  INFO 18976 --- [           main] hello.aop.exam.aop.TraceAspect           : [trace] void hello.aop.exam.ExamService.request(String) args=[data4]

2022-02-19 12:49:48.433  INFO 18976 --- [           main] hello.aop.exam.aop.TraceAspect           : [trace] String hello.aop.exam.ExamRepository.save(String) args=[data4]

2022-02-19 12:49:48.433  INFO 18976 --- [           main] hello.aop.exam.aop.RetryAspect           : [retry] String hello.aop.exam.ExamRepository.save(String) retry=@hello.aop.exam.annotation.Retry(value=4)

2022-02-19 12:49:48.433  INFO 18976 --- [           main] hello.aop.exam.aop.RetryAspect           : [retry] try count=1/4

2022-02-19 12:49:48.433  INFO 18976 --- [           main] hello.aop.exam.aop.RetryAspect           : [retry] try count=2/4

spring디자인-패턴

Quiz

46% of people got it wrong. Give it a try!

Spring AOP helps effectively handle auxiliary functions (cross-cutting concerns) that repeatedly appear across multiple modules, outside of an application's core business logic. What type of concerns do Logging or Retry fall under?

Core Business Logic

Data Model

Cross-cutting Concerns

User Interface

Answer 2

1

RetryAspect는 예외발생시에만 실행되는건 아니고

@Retry가 붙은 메서드 실행 시에 해당 로직이 실행이 되며,

예외 발생시 예외처리를 하는 거라고 생각하시면 될거 같네요.

sulum1140님의 프로필 이미지
sulum1140
Questioner

감사합니다!

0

yh님의 프로필 이미지
yh
Instructor

안녕하세요. 황정열님

로그 마지막에 [retry] try count=1/4,  [retry] try count=2/4  부분을 확인하실 수 있습니다.

감사합니다.

sulum1140's profile image
sulum1140

asked

Ask a question