|
|
@ -49,12 +49,9 @@ public class MapLogisticSseServiceImpl implements IMapLogisticSseService { |
|
|
|
public SseEmitter SseSubscribe(String clientId) { |
|
|
|
public SseEmitter SseSubscribe(String clientId) { |
|
|
|
KiccUser kiccUser = getUser(); |
|
|
|
KiccUser kiccUser = getUser(); |
|
|
|
Optional.ofNullable(clientId).orElseThrow(() -> new CommonException("当前客户端Id为空,请检查后重试!")); |
|
|
|
Optional.ofNullable(clientId).orElseThrow(() -> new CommonException("当前客户端Id为空,请检查后重试!")); |
|
|
|
|
|
|
|
sseSignalContainers.removeIf(item -> StrUtil.equals(item.getClientId(), clientId) && StrUtil.equals(item.getTenantId(), kiccUser.getTenantId())); |
|
|
|
// 设置超时时间为1小时
|
|
|
|
// 设置超时时间为1小时
|
|
|
|
SseEmitter sseEmitter = new SseEmitter(3600_000L); |
|
|
|
SseEmitter sseEmitter = new SseEmitter(3600_000L); |
|
|
|
doMaintenance(); |
|
|
|
|
|
|
|
if(sseSignalContainers.stream() |
|
|
|
|
|
|
|
.filter(item -> StrUtil.equals(item.getClientId(),clientId) && StrUtil.equals(item.getTenantId(), kiccUser.getTenantId())) |
|
|
|
|
|
|
|
.collect(Collectors.toSet()).isEmpty()) { |
|
|
|
|
|
|
|
SseSignalContainer sseSignalContainer =new SseSignalContainer( |
|
|
|
SseSignalContainer sseSignalContainer =new SseSignalContainer( |
|
|
|
clientId, |
|
|
|
clientId, |
|
|
|
kiccUser.getId(), |
|
|
|
kiccUser.getId(), |
|
|
@ -77,7 +74,6 @@ public class MapLogisticSseServiceImpl implements IMapLogisticSseService { |
|
|
|
log.info("clientId:{},当前用户Id为:{}的SSE长轮询出现异常,正在删除当前的建立通道对象,错误信息{}", clientId, kiccUser.getId(), e.getLocalizedMessage()); |
|
|
|
log.info("clientId:{},当前用户Id为:{}的SSE长轮询出现异常,正在删除当前的建立通道对象,错误信息{}", clientId, kiccUser.getId(), e.getLocalizedMessage()); |
|
|
|
sseSignalContainers.removeIf(item -> StrUtil.equals(item.getClientId(), clientId) && StrUtil.equals(item.getTenantId(), kiccUser.getTenantId())); |
|
|
|
sseSignalContainers.removeIf(item -> StrUtil.equals(item.getClientId(), clientId) && StrUtil.equals(item.getTenantId(), kiccUser.getTenantId())); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else throw new CommonException("客户端id重复,请重新设置确保唯一"); |
|
|
|
|
|
|
|
return sseEmitter; |
|
|
|
return sseEmitter; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|