com.netflix.hystrix.exception.HystrixRuntimeException: AddressClient#getByIds(List) failed and no fa

出现这个问题的时候。一般是A服务调用B服务报的错。

addressIds = results.stream().map(e -> e.getAddressId()).filter(e -> null != e).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(addressIds))
    addressMap = addressServices.getByIds(addressIds);
@GetMapping(value = "/v1/address/s", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
Map getByIds(@RequestParam(value = "ids", required = true) List ids);


如果数据少的话调用这个接口是正常的,但当数据长于1千条就报错。最后发现。B项目的参数是GET请求@RequestParam。这个会有长度的要求。我们改为另一个POST请求。再试一次就好了

addressIds = results.stream().map(e -> e.getAddressId()).filter(e -> null != e).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(addressIds))
	addressMap = addressServices.byIds(addressIds);
@PostMapping(value = "/v1/address/byIds", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
Map byIds(@RequestBody List ids);

 

你可能感兴趣的:(代码常用知识)