• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

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

22.02.19 12:51 작성 조회수 367

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

답변 2

·

답변을 작성해보세요.

1

만찐두빵님의 프로필

만찐두빵

2022.03.01

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

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

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

황정열님의 프로필

황정열

질문자

2022.03.02

감사합니다!

0

안녕하세요. 황정열님

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

감사합니다.