我正在使用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宕机),超时等。
openfeign
的方法,而不是Spring的Feign客户端作为bean。 - WesternGun