inflearn logo
강의

Khóa học

Chia sẻ kiến thức

Nguyên tắc cốt lõi của Spring - Nâng cao

Thử lại AOP

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

605

sulum1140

9 câu hỏi đã được viết

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 디자인-패턴

Câu trả lời 2

1

zzindu

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

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

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

0

sulum1140

감사합니다!

0

yh

안녕하세요. 황정열님

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

감사합니다.

어드바이스 순서 디폴트 기준이 궁금합니다.

0

56

1

AspectV1 예제를 @Configuration 수동 등록으로도 가능한가요?

0

83

2

구체 클래스를 상속받아 확장한 형태도 클래스패턴/데코레이터 패턴이라고 칭하나요?

0

57

1

TraceTemplate 을 미리 빈으로 등록해서 사용할때 이렇게 설정하는게 맞는건가요?

0

54

1

Decorator 에서 추상메서드로 뺄때 질문 있습니다.

0

57

1

대상 클래스에 기본 생성자가 없을 때

0

77

1

스프링 부트 버전 4.0 aop 의존성 명칭 변경

1

371

2

final 키워드 사용 관련 질문

0

78

1

안녕하세요

0

68

1

ThradLocal 실무 사례

0

98

2

실무에서의 동시성 문제

0

65

1

로그 등 부가 기능에 대한 테스트코드

0

51

1

ProceedingJoinPoint와 MethodInvocation에 대하여

0

67

1

실무 멀티스레딩에 대한 궁금증

0

70

1

안녕하세요 질문있습니다

0

45

1

AspectV3 aop 실행 순서 문의 드립니다

0

38

1

MDC vs AOP 중에 고민중입니다.

0

77

1

순환참조

0

162

2

this를 단독으로 사용할때랑 파라미터 바인딩 할때 차이

0

78

1

빈 후처리에 등록 질문 있습니다.

0

79

1

AppConfig 설정하는 설명중에 이해가 안되는게 있습니다.

0

91

1

ThreadLocal을 지역변수로 선언하면 remove가 필요할까요?

0

118

2

@Aspect 어노테이션으로 생성된 Advisor의 Bean 저장 여부

0

70

1

ThreadLocal 사용시 부작용이 있을수 있을까요? (ThreadLocal.remove()를 잘한다고 해도..)

0

73

2