Class SseEventSource.Builder
- Enclosing interface:
- SseEventSource
SseEventSource
builder class.
Event source builder provides methods that let you conveniently configure and subsequently build a new
SseEventSource
instance. You can obtain a new event source builder instance using a static
SseEventSource.target(endpoint)
factory method.
For example:
SseEventSource es = SseEventSource.target(endpoint) .reconnectingEvery(5, SECONDS) .build(); es.register(System.out::println); es.open();
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Name of the property identifying theSseEventSource.Builder
implementation to be returned fromnewBuilder()
. -
Constructor Summary
ModifierConstructorDescriptionprotected
Builder()
Allows custom implementations to extend the SSE event source builder class. -
Method Summary
Modifier and TypeMethodDescriptionabstract SseEventSource
build()
Build new SSE event source pointing at a SSE streamingweb target
.abstract SseEventSource.Builder
reconnectingEvery
(long delay, TimeUnit unit) Set the initial reconnect delay to be used by the event source.protected abstract SseEventSource.Builder
-
Field Details
-
JAXRS_DEFAULT_SSE_BUILDER_PROPERTY
Name of the property identifying theSseEventSource.Builder
implementation to be returned fromnewBuilder()
.- See Also:
-
-
Constructor Details
-
Builder
protected Builder()Allows custom implementations to extend the SSE event source builder class.
-
-
Method Details
-
target
-
reconnectingEvery
Set the initial reconnect delay to be used by the event source.Note that this value may be later overridden by the SSE endpoint using either a
retry
SSE event field orHTTP 503 + "Retry-After"
mechanism as described in theSseEventSource
javadoc.- Parameters:
delay
- the default time to wait before attempting to recover from a connection loss.unit
- time unit of the reconnect delay parameter.- Returns:
- updated event source builder instance.
-
build
Build new SSE event source pointing at a SSE streamingweb target
.The returned event source is ready, but not
connected
to the SSE endpoint. It is expected that you will manually invoke itsSseEventSource.open()
method once you are ready to start receiving SSE events. In case you want to build an event source instance that is already connected to the SSE endpoint, use the event source builderSseEventSource.open()
method instead.Once the event source is open, the incoming events are processed by the event source in an asynchronous task that runs in an internal single-threaded
scheduled executor service
.- Returns:
- new event source instance, ready to be connected to the SSE endpoint.
- See Also:
-