Skip to content

Instantly share code, notes, and snippets.

// The two things I see in every SSE example:
@GET @Produces(MediaType.SERVER_SENT_EVENTS)
public void eventStream(@Context SseEventSink eventSink, @Context Sse sse) {
// starting a separate thread to handle the complete request within
// the context of the method
executor.execute(() -> {
// try-with-resources: closing the resource also in the method
try(SseEventSink sink = eventSink) {