public interface SseEventSink extends AutoCloseable, Flow.Subscriber<OutboundSseEvent>
The instance of SseEventSink can be only acquired by injection of a resource method parameter:
@GET
@Path("eventStream")
@Produces(MediaType.SERVER_SENT_EVENTS)
public void eventStream(@Context SseEventSink eventSink) {
// ...
}
The injected instance is then considered as a return type, so the resource method doesn't return anything,
similarly as in server-side async processing.
The underlying client connection is kept open and the application code is able to send events. A server-side instance implementing the interface corresponds exactly to a single client HTTP connection.
The injected instance is thread safe.
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the
SseEventSink instance. |
boolean |
isClosed()
Check if the stream has been closed already.
|
onComplete, onError, onNext, onSubscribeboolean isClosed()
Please note that the client connection represented by this SseServerSink can be closed by the
client side when a client decides to close connection and disconnect from the server.
true when closed, false otherwise.void close()
SseEventSink instance.
Subsequent calls have no effect and are ignored. Once the SseEventSink is closed, invoking any
other method on the event sink instance would result in an IllegalStateException being thrown.
close in interface AutoCloseableCopyright © 1996-2017, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.