서버 전송 이벤트(Server-Sent Events, SSE) 및 웹소켓

서버 전송 이벤트(Server-Sent Events, SSE) 및 웹소켓 1. 서버 전송 이벤트(SSE)란? 정의 : SSE는 클라이언트와 서버 간에 한 방향 통신을 제공하는 웹 표준입니다. 기능 : 서버가 클라이언트에게 새로운 데이터가 있을 때마다 푸시할 수 있습니다. 2. 웹소켓이란? 정의 : 웹소켓은 클라이언트와 서버 간의 양방향 통신을 제공합니다. 적용 : 실시간 상호작용이 필요한 애플리케이션에 적합합니다. 3. Spring Boot에서 SSE 구현 Spring WebFlux 사용 : 비동기 처리와 백프레셔 관리에 유용합니다. Spring MVC 사용 : SseEmitter 를 사용하여 SSE 구현 가능합니다. 4. WebFlux 구현 예시 Notification.java : public class Notification { private final int id; private final String content; public Notification(int id, String content) { this.id = id; this.content = content; } // getters ... } SseController.java : import org.springframework.http.codec.ServerSentEvent; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import reactor.core.publisher.Flux; import java.time.Duration; import java.util.stream.Stream; @RestController public class SseController { private List<Notifica...