우선, 오류 가보고 된 후에는 재 시도가 아니지만로드 밸런싱 클라이언트가 원격 요청 인스턴스를 사용할 수 없음을 발견 한 후 다른 인스턴스에 대한 재 시도입니다.
@bean@loadbalancedresttemplate resttemplate () {httpcomponentsclienthttprequestFactory httprequestFactory = new httpComponentsClienthttprequestFactory (); httprequestfactory.setreadtimeout (5000); httprequestfactory.setConnectTimeout (5000); 새로운 resttemplate를 반환합니다 (httprequestfactory);}회복 메커니즘
Feign은 자체적으로 패키지 된 레트리어를 통해 구성을 재 시도하고 있으며 기본값은 5 배입니다.
패키지 feign; static java.util.concurrent.seconds;/*** {@link client#execute (request, feign.request.options)}에 대한 각 호출에 대해 클로닝되었습니다. * 구현은 재시도 작업이 계속되어야하는지 여부를 결정하기 위해 상태를 유지할 수 있습니다. * /public interface Retryer는 복제 가능한 연장 { /*** 리트리가 허용되면 반환 (수면 후). 그렇지 않으면 예외를 전파합니다. */ void contorityorPropagate (retryableException e); 레트리 클론 (); 공개 정적 클래스 기본 구현 레트 리더 {개인 최종 int MaxAttempts; 개인 최종 장기; 개인 최종 Long Maxperiod; int 시도; 긴 셀프 포르 밀리스; public default () {this (100, seconds.tomillis (1), 5); } public default (긴 기간, 긴 maxperiod, int maxattempts) {this.period = period; this.maxperiod = maxperiod; this.maxattempts = maxattempts; this.attempt = 1; } Feign Cance Rech
@bean retryer feignretryer () {return retryer.never_retry; } Feign 요청 시간 초과 설정
@beanRequest.Options requestOptions (configurableEnvironment env) {int ribbonreadtimeout = env.getProperty ( "ribbon.Readtimeout", int.class, 6000); int ribbonconnectiontimeout = env.getProperty ( "ribbon.connecttimeout", int.class, 3000); 새 요청을 반환합니다. options (ribbonConnectionTimeout, ribbonReadtimeout);}위는이 기사의 모든 내용입니다. 모든 사람의 학습에 도움이되기를 바랍니다. 모든 사람이 wulin.com을 더 지원하기를 바랍니다.