文件系统,设备升级
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
package com.njcn.access.utils;
|
||||
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.njcn.access.enums.AccessResponseEnum;
|
||||
import com.njcn.access.pojo.dto.NoticeUserDto;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -25,6 +29,7 @@ import java.nio.charset.StandardCharsets;
|
||||
@AllArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
public class SendMessageUtil {
|
||||
private final RedisUtil redisUtil;
|
||||
|
||||
@Value("${app.sendUrl:https://fc-mp-ff7b310f-94c9-4468-8260-109111c0a6b2.next.bspapp.com/push}")
|
||||
private String appSendUrl;
|
||||
@@ -67,4 +72,27 @@ public class SendMessageUtil {
|
||||
e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 轮询 Redis 等待响应
|
||||
*/
|
||||
public String waitForResponse(String guid, int timeoutSeconds) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
while (System.currentTimeMillis() - startTime < timeoutSeconds * 1000L) {
|
||||
String response = redisUtil.getStringByKey(AppRedisKey.COMMON_RESOPNSE + guid);
|
||||
if (response != null) {
|
||||
redisUtil.delete(AppRedisKey.COMMON_REQUEST + guid);
|
||||
redisUtil.delete(AppRedisKey.COMMON_RESOPNSE + guid);
|
||||
return response;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(100); // 100ms 轮询一次
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
throw new BusinessException(AccessResponseEnum.TIME_OUT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user