diff --git a/src/main/java/com/nexters/moyeomoyeo/notification/handler/SseEmitterHandler.java b/src/main/java/com/nexters/moyeomoyeo/notification/handler/SseEmitterHandler.java index f7382d6..9f1cbd4 100644 --- a/src/main/java/com/nexters/moyeomoyeo/notification/handler/SseEmitterHandler.java +++ b/src/main/java/com/nexters/moyeomoyeo/notification/handler/SseEmitterHandler.java @@ -34,14 +34,14 @@ public void add(String teamBuildingUuid, SseEmitter emitter) { emitterList.add(emitter); emitterMap.put(teamBuildingUuid, emitterList); - log.info("new emitter added: {}", emitter); + log.info("new emitter added: {}, {}", teamBuildingUuid, emitter); log.info("emitter list size: {}", emitterList.size()); emitter.onCompletion(() -> { - log.info("onCompletion callback"); + log.info("onCompletion callback : {}", emitter); emitterList.remove(emitter); }); emitter.onTimeout(() -> { - log.info("onTimeout callback"); + log.info("onTimeout callback : {}", emitter); emitterList.remove(emitter); }); } diff --git a/src/main/java/com/nexters/moyeomoyeo/notification/service/NotificationService.java b/src/main/java/com/nexters/moyeomoyeo/notification/service/NotificationService.java index 15c1757..1f51008 100644 --- a/src/main/java/com/nexters/moyeomoyeo/notification/service/NotificationService.java +++ b/src/main/java/com/nexters/moyeomoyeo/notification/service/NotificationService.java @@ -1,7 +1,6 @@ package com.nexters.moyeomoyeo.notification.service; import com.nexters.moyeomoyeo.notification.handler.SseEmitterHandler; -import java.io.IOException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -12,7 +11,8 @@ @RequiredArgsConstructor public class NotificationService { - private static final Long DEFAULT_TIMEOUT = 60L * 1000 * 30; + //TODO 시간 원복 + private static final Long DEFAULT_TIMEOUT = 60L * 1000 * 1; private final SseEmitterHandler handler; @@ -21,15 +21,15 @@ public void sendNotification(SseEmitter emitter, String name, Object data) { emitter.send(SseEmitter.event() .name(name) .data(data)); - } catch (IOException e) { + } catch (Exception e) { log.error("fail to send message : {}", emitter); } } public SseEmitter subscribe(String teamBuildingUuid) { final SseEmitter emitter = new SseEmitter(DEFAULT_TIMEOUT); - sendNotification(emitter, "subscribe", "subscribe completed"); handler.add(teamBuildingUuid, emitter); + sendNotification(emitter, "subscribe", "subscribe completed"); return emitter; }