public class SseEventSourceImpl extends Object implements SseEventSource
Modifier and Type | Class and Description |
---|---|
static class |
SseEventSourceImpl.SourceBuilder |
SseEventSource.Builder
Modifier and Type | Field and Description |
---|---|
static long |
RECONNECT_DEFAULT |
Constructor and Description |
---|
SseEventSourceImpl(WebTarget target) |
SseEventSourceImpl(WebTarget target,
boolean open) |
Modifier and Type | Method and Description |
---|---|
boolean |
close(long timeout,
TimeUnit unit)
Close this event source and wait for the internal event processing task to complete
for up to the specified amount of wait time.
|
boolean |
isOpen()
Check if this event source instance has already been
opened . |
void |
open()
Open the connection to the supplied SSE underlying
web target and start processing incoming
events . |
void |
open(String lastEventId) |
void |
open(String lastEventId,
String verb,
Entity<?> entity,
MediaType... mediaTypes) |
void |
register(Consumer<InboundSseEvent> onEvent)
Register a
InboundSseEvent consumer. |
void |
register(Consumer<InboundSseEvent> onEvent,
Consumer<Throwable> onError)
Register
InboundSseEvent and Throwable consumers. |
void |
register(Consumer<InboundSseEvent> onEvent,
Consumer<Throwable> onError,
Runnable onComplete)
Register
InboundSseEvent and Throwable consumers and onComplete callback. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, target
public static final long RECONNECT_DEFAULT
public SseEventSourceImpl(WebTarget target)
public SseEventSourceImpl(WebTarget target, boolean open)
public void open()
SseEventSource
web target
and start processing incoming
events
.open
in interface SseEventSource
public void open(String lastEventId)
public boolean isOpen()
SseEventSource
opened
.isOpen
in interface SseEventSource
true
if this event source is open, false
otherwise.public void register(Consumer<InboundSseEvent> onEvent)
SseEventSource
InboundSseEvent
consumer.
Given consumer is invoked once per each received event.
register
in interface SseEventSource
onEvent
- event consumer.public void register(Consumer<InboundSseEvent> onEvent, Consumer<Throwable> onError)
SseEventSource
InboundSseEvent
and Throwable
consumers.
Event consumer is invoked once per each received event, Throwable
consumer is invoked invoked upon a
unrecoverable error encountered by a SseEventSource
.
register
in interface SseEventSource
onEvent
- event consumer.onError
- error consumer.public void register(Consumer<InboundSseEvent> onEvent, Consumer<Throwable> onError, Runnable onComplete)
SseEventSource
InboundSseEvent
and Throwable
consumers and onComplete callback.
Event consumer is invoked once per each received event, Throwable
consumer is invoked invoked upon a
unrecoverable error encountered by a SseEventSource
, onComplete callback is invoked when there are no
further events to be received.
register
in interface SseEventSource
onEvent
- event consumer.onError
- error consumer.onComplete
- onComplete handler.public boolean close(long timeout, TimeUnit unit)
SseEventSource
The method blocks until the event processing task has completed execution after a shutdown request, or until the timeout occurs, or the current thread is interrupted, whichever happens first.
In case the waiting for the event processing task has been interrupted, this method restores
the interrupt
flag on the thread before returning false
.
close
in interface SseEventSource
timeout
- the maximum time to wait.unit
- the time unit of the timeout argument.true
if this executor terminated and false
if the timeout elapsed
before termination or the termination was interrupted.Copyright © 2021 JBoss by Red Hat. All rights reserved.