fix(sse): 修复心跳推送异常处理

- 捕获 IOException 异常时,增加日志记录错误信息
- 尝试完成 SseEmitter 的生命周期,避免资源泄露
- 如果完成 SseEmitter 时发生异常,同样增加日志记录
This commit is contained in:
2025-05-27 23:08:39 +08:00
parent 992a32e35d
commit 3d0ce9b627

View File

@@ -40,7 +40,15 @@ public class SseService {
"event",
"heartbeat")));
} catch (IOException e) {
throw new RuntimeException(e);
log.error("{} send heartbeat error:{}", topicId, e.getMessage());
try{
emitter.complete();
}catch (Exception exception){
log.error("{} emitter complete error:{}", topicId, exception.getMessage());
}
}
},
Duration.ofMinutes(1));