继续潜水

导航

 

git地址: https://github.com/rholder/guava-retrying

 

public ListResult getFileUrls(String fileCodes){
        try {
            log.info("[调用服务][common-获取文件路径]开始:{}",fileCodes);
            return RetryerBuilder.<ListResult>newBuilder()
                    .retryIfException()
                    .withStopStrategy(StopStrategies.stopAfterAttempt(3))
                    .build().call(() -> {
                        String url =apiDomainConfig.getOuterApiDomainCommon() + "/ossFile/getFileUrls";
                        JSONObject json = new JSONObject();
                        json.put("fileCodes",fileCodes);
                        ListResult listResult =  clientService.getRestTemplate( json , url , ListResult.class);
                        return listResult;
                    });
        } catch (Exception e) {
            log.error("[调用服务][common-获取文件路径]补偿失败3次",e);
            return Resulter.listResult(BaseCodeEnum.NETWORK_ERROR);
        } finally {
            log.info("[调用服务][common-获取文件路径]结束");
        }
    }

 

posted on 2020-04-16 15:19  继续潜水  阅读(500)  评论(0编辑  收藏  举报