添加重试

This commit is contained in:
shikong 2023-12-25 14:11:17 +08:00
parent f1db3e3d1d
commit 21f2a50952

View File

@ -355,7 +355,7 @@ public class WvpService {
schedule.cancel(true);
}
String token = login();
final String[] token = {login()};
Retryer<Optional<DeviceChannel>> defaultGenericRetryer = RetryerBuilder.<Optional<DeviceChannel>>newBuilder()
// 异常就重试
.retryIfException()
@ -370,10 +370,11 @@ public class WvpService {
if (attempt.hasException()) {
log.info("异常 {}", attempt.getExceptionCause().getMessage());
cache.remove("token");
token[0] = login();
}
}
}).build();
Optional<DeviceChannel> deviceChannel = defaultGenericRetryer.call(() -> getDeviceChannelByDeviceCode(token, deviceCode));
Optional<DeviceChannel> deviceChannel = defaultGenericRetryer.call(() -> getDeviceChannelByDeviceCode(token[0], deviceCode));
if (deviceChannel.isEmpty()) {
result.setResult(JsonResponse.error(MessageFormat.format("未能获取 设备: {0} 的通道信息", deviceCode)));
@ -384,7 +385,7 @@ public class WvpService {
log.info("设备通道信息 => {}", dc);
try {
StreamContent data = wvpProxyClient.playStart(token, dc.getDeviceId(), dc.getChannelId()).getData();
StreamContent data = wvpProxyClient.playStart(token[0], dc.getDeviceId(), dc.getChannelId()).getData();
log.info("实时流信息 {}", data);
String url = StringUtils.joinWith("/",