mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-07-26 07:28:58 +08:00
fix(sse): 修复心跳推送异常处理
- 捕获 IOException 异常时,增加日志记录错误信息 - 尝试完成 SseEmitter 的生命周期,避免资源泄露 - 如果完成 SseEmitter 时发生异常,同样增加日志记录
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user