2017-01-26 5 views
0

가능한 가장 간단한 재시도 시나리오를 시도했습니다. 재 시도는 실행시 무시됩니다.@Retryable이 실행되고 있지 않습니다.

Application.java :

이 서비스 클래스 내에
@SpringBootApplication 
@EnableRetry 
public class Application extends SpringBootServletInitializer { 
//... 

: (같은 클래스 내에서) @Retryable 방법에

public Boolean processItem() { 
    Long id = 999L; 
    try { 
     retrieveItemWithRetry(id); 
     return true; 
    } catch (NoResultException e) { 
     return false; 
    } 
} 

@Retryable(include=NoResultException.class, backoff = @Backoff(delay = 500, maxDelay = 3000), maxAttempts = 5) 
private void retrieveItemWithRetry(Long id) { 
    retrieveItem(id); 
} 

private OrderRequest retrieveItem(Long id) { 
    throw new NoResultException(); 
}  

답변

4

내부 호출을 다시 시도하지 않습니다; 어제의 my answer here을 참조하십시오. 이유를 설명합니다.

또한 @Retryable 메서드는 공개되어야합니다.

+0

감사합니다. @Gary, 레코드의 경우'@ Retryable '클래스가 호출 클래스에 삽입 된'@ Component'인지 확인해야했습니다. –