2014-10-09 3 views
2

우리는 우리의 응용 프로그램에서 RabbitMQ를 사용하여 지불 요청을 대기열에 올리고 결과를 발신자에게 다시 보냅니다. 두 경우 모두 클라이언트가 영원히 재 시도 할 재시도 정책을 요청했지만 "재시도 트랜잭션 ..."과 같이 재 시도 할 때마다 로그에 항목을 넣습니다. 그러면 외부 시스템이 모니터링을 통해 물건 백업을 감지 할 수 있습니다 로그 파일토끼 메시지 다시 시도시 로깅 메시지

public SimpleMessageListenerContainer paymentListenerContainer() { 
    final SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); 
    container.setConnectionFactory(rabbitConnectionFactory()); 
    container.setQueues(paymentQueue()); 
    container.setMessageListener(cpmPaymentListener()); 
    container.setConcurrentConsumers(configurationService.getAmqpConcurrentConsumers()); 
    container.setMaxConcurrentConsumers(configurationService.getAmqpMaxConcurrentConsumers()); 
    container.setAdviceChain(new Advice[] { paymentRetryInterceptor() }); 
    return container; 
} 

따라서 재시도 논리를 정의 :

나는 이렇게 리스너 컨테이너를 만드는거야

public RetryOperationsInterceptor paymentRetryInterceptor() { 
    return RetryInterceptorBuilder.stateless() 
      .maxAttempts(configurationService.getPaymentRetryMaxAttempts()) 
      .backOffOptions(configurationService.getPaymentRetryInitialInterval(), configurationService.getPaymentRetryMultiplier(), configurationService.getPaymentRetryMaxInterval()) // initialInterval, multiplier, maxInterval 
      .build(); 
} 

그래서 다시 시도가 완벽하게 작동하지만 실제로 기록 할 후크를 찾을 수 없습니다 재 시도에 관한 건. 내가 빠진 것이 있습니까? 다시 시도 할 때 뭔가를 실행할 어딘가에 고리가 있습니까? 내가 서브 클래 싱 할 수있는 것? 아니면 그냥 내 로거 설정에서 사용할 수있는 봄의 재시도 논리에 묻힌 일부 exsting 로깅이 있습니까?

감사합니다.

Chris.

답변

3

당신은 org.springframework.retry.support.RetryTemplate 범주에 대해 DEBUG 수준에서 전환 할 수 있습니다 당신은 같은 로그 무언가에 볼 수 있습니다 :

2014-10-09 20:18:51,126 DEBUG main [org.springframework.retry.support.RetryTemplate] - <Retry: count=0> 
2014-10-09 20:18:51,140 DEBUG main [org.springframework.retry.support.RetryTemplate] - <Checking for rethrow: count=1> 
2014-10-09 20:18:51,140 DEBUG main [org.springframework.retry.support.RetryTemplate] - <Retry: count=1> 
2014-10-09 20:18:51,141 DEBUG main [org.springframework.retry.support.RetryTemplate] - <Checking for rethrow: count=2> 
2014-10-09 20:18:51,141 DEBUG main [org.springframework.retry.support.RetryTemplate] - <Retry: count=2> 
2014-10-09 20:18:51,141 DEBUG main [org.springframework.retry.support.RetryTemplate] - <Checking for rethrow: count=3> 
2014-10-09 20:18:51,141 DEBUG main [org.springframework.retry.support.RetryTemplate] - <Retry failed last attempt: count=3> 
+0

감사합니다! 그것은 내가 찾고 있었던 바로 그 것이다. – cpaynter