Browse Source

事项基本信息IRS接口超时重试重新设置签名和时间戳

master
CMM 4 months ago
parent
commit
af2081423d
1 changed files with 12 additions and 1 deletions
  1. +12
    -1
      kq-vas-api/src/main/java/com/ningdatech/kqapi/irs/manage/IrsManage.java

+ 12
- 1
kq-vas-api/src/main/java/com/ningdatech/kqapi/irs/manage/IrsManage.java View File

@@ -121,10 +121,15 @@ public class IrsManage {
return responseBody;
}

private static String retryAndGetResponseBody(String responseBody, HttpRequest request) {
private String retryAndGetResponseBody(String responseBody, HttpRequest request) {
if (responseBody.contains("Read timed out")){
int retries = 3;
for (int i = 0; i < retries; i++) {
// 重新设置签名和时间戳
long timestamp = System.currentTimeMillis();
String sign = MD5.create().digestHex(appKey + appSecret + timestamp);
request.header("requestTime", String.valueOf(timestamp));
request.header("sign", sign);
responseBody = request.execute().body();
ParserConfig config = new ParserConfig();
config.propertyNamingStrategy = PropertyNamingStrategy.PascalCase;
@@ -138,6 +143,12 @@ public class IrsManage {
if (i == retries - 1){
throw BizException.wrap("事项基本信息列表接口调用失败!");
}
// 等待一段时间后再次尝试
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
return responseBody;


Loading…
Cancel
Save