Spring SSE(Server-Sent Events)
1. 개요
2. SSE 구현
2.1. 컨트롤러 구현
@RestController
class NotificationRouter {
@GetMapping("/notification")
suspend fun streamNotification(): Flow<ServerSentEvent<String>> =
Flux.interval(Duration.ofSeconds(1))
.map { sequence ->
ServerSentEvent
.builder<String>()
.id(sequence.toString())
.event("periodic-event")
.data("\\"SSE\\" : \\"${LocalDate.now()}\\"")
.build()
}
.asFlow()
}2.2. 테스트 구현
3. SSE 이해
4. 예제 코드
5. 참고
Last updated
