【发布时间】:2018-03-21 14:19:19
【问题描述】:
我正在使用 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 Client(LocationClient) 做异常处理(即我只是不希望每个调用者都这样做。这应该是 LocationClient 的一部分)。异常可能是连接被拒绝(如果 LocationService 已关闭)、超时等。
【问题讨论】:
标签: spring-boot spring-cloud-feign