I have following Quarkus resource:
@Path("/myResource")
class MyResource {
@GET
@Path("/eventStream")
@Produces(MediaType.SERVER_SENT_EVENTS)
@SseElementType(MediaType.APPLICATION_JSON)
fun stream(): Multi<MyDto> = deviceStatusService.getStream()
}
This will produce events without event name and only the data section. How can I specify an event name?
My final code is now:
@GET
@Path("/eventStream")
@Produces(MediaType.SERVER_SENT_EVENTS)
@SseElementType(MediaType.APPLICATION_JSON)
fun stream(@Context sse: Sse, @Context sseEventSink: SseEventSink) {
deviceStatusService.getStream().subscribe().with { deviceStatus ->
sseEventSink.send(sse.newEventBuilder()
.name("deviceStatus")
.data(deviceStatus)
.build())
}
}