2017-10-10 3 views
0

피싱 클라이언트를 사용 중입니다.Feign 클라이언트 오류 처리

위치 서비스를 가지고 있습니다. 그래서 FeignClient를 사용하여 내 LocationService 용 클라이언트를 만들었습니다.

@FeignClient(url="http://localhost:9003/location/v1", name="location-service") 
public interface LocationControllerVOneClient { 

    @RequestMapping(value = "/getMultipleLocalities", method = RequestMethod.POST) 
    public Response<Map<Integer, Locality>> getMultipleLocalities(List<Integer> localityIds); 

    @RequestMapping(value = "/getMultipleCities", method = RequestMethod.POST) 
    public Response<Map<Integer, City>> getMultipleCities(List<Integer> cityIds); 

    @RequestMapping(value = "/getMultipleStates", method = RequestMethod.POST) 
    public Response<Map<Integer, State>> getMultipleStates(List<Integer> stateIds); 

    @RequestMapping(value = "/getMultipleCitiesName", method = RequestMethod.POST) 
    public Response<Map<Integer, String>> getMultipleCitiesName(MultiValueMap<String, String> formParams); 

    @RequestMapping(value = "/getMultipleStatesName", method = RequestMethod.POST) 
    public Response<Map<Integer, String>> getMultipleStatesName(MultiValueMap<String, String> formParams); 

    @RequestMapping(value = "/getMultipleLocalitiesName", method = RequestMethod.POST) 
    public Response<Map<Integer, String>> getMultipleLocalitiesName(MultiValueMap<String, String> formParams); 

} 

이제 다른 서비스는 LocationClient를 통해이 LocationService를 호출 할 수 있습니다.

이 Feign 클라이언트 (LocationClient)에 대한 예외 처리를 일반적인 장소에서하고 싶습니다. 즉, 각 발신자가 LocationClient에 속해야합니다. 예외, 시간 제한 등 (LocationService가 다운 된 경우) 연결이 거부 될 수

답변

0
까지 거부 타임 아웃 또는 연결과 같은 예외가 올 때

당신은 호출되는 대체 클라이언트를 정의 할 수 있습니다

@FeignClient(url="http://localhost:9003/location/v1", name="location-service", fallback=LocationFallbackClient.class) 
public interface LocationControllerVOneClient { 
    ... 
} 

LocationFallbackClientLocationControllerVOneClient를 구현해야합니다 .

관련 문제