Interface SseBroadcaster
- All Superinterfaces:
- AutoCloseable
public interface SseBroadcaster extends AutoCloseable
 Server broadcaster can be used to manage multiple server sinks. It enables sending events to all
 registered event outputs and provides facility to effectively handle exceptions and closures of individual registered
 event outputs.
 
Instance of this interface is thread safe, meaning that it can be shared and its method invoked from different threads without causing inconsistent internal state.
- Since:
- 2.1
- Author:
- Marek Potociar
- 
Method SummaryModifier and Type Method Description CompletionStage<?>broadcast(OutboundSseEvent event)Publish an SSE event to all registeredSseEventSinkinstances.voidclose()Close the broadcaster and all registeredSseEventSinkinstances.voidonClose(Consumer<SseEventSink> onClose)Register a listener, which will be called when this SseBroadcaster closes a given eventSseEventSinkor tries to write to a givenSseEventSinkthat is already closed (either by client closing the connection or by callingSseEventSink.close()on the server side.voidonError(BiConsumer<SseEventSink,Throwable> onError)Register a listener, which will be called when an exception is thrown by a givenSseEventSinkwhen this SseBroadcaster tries to write to it or close it.voidregister(SseEventSink sseEventSink)Register providedSseEventSinkinstance to thisSseBroadcaster.
- 
Method Details- 
onErrorRegister a listener, which will be called when an exception is thrown by a givenSseEventSinkwhen this SseBroadcaster tries to write to it or close it.This operation is potentially slow, especially if large number of listeners get registered in the broadcaster. The SseBroadcasterimplementation is optimized to efficiently handle small amounts of concurrent listener registrations and removals and large amounts of registered listener notifications.- Parameters:
- onError- bi-consumer, taking two parameters:- SseEventSink, which is the source of the error and the actual- Throwableinstance.
 
- 
onCloseRegister a listener, which will be called when this SseBroadcaster closes a given eventSseEventSinkor tries to write to a givenSseEventSinkthat is already closed (either by client closing the connection or by callingSseEventSink.close()on the server side.This operation is potentially slow, especially if large number of listeners get registered in the broadcaster. The SseBroadcasterimplementation is optimized to efficiently handle small amounts of concurrent listener registrations and removals and large amounts of registered listener notifications.- Parameters:
- onClose- consumer taking single parameter, a- SseEventSink, which was closed.
 
- 
registerRegister providedSseEventSinkinstance to thisSseBroadcaster.- Parameters:
- sseEventSink- to be registered.
 
- 
broadcastPublish an SSE event to all registeredSseEventSinkinstances.- Parameters:
- event- SSE event to be published.
- Returns:
- completion stage that completes when the event has been broadcast to all registered event sinks.
 
- 
closevoid close()Close the broadcaster and all registeredSseEventSinkinstances.Any other resources associated with the SseBroadcastershould be released.Subsequent calls have no effect and are ignored. Once the SseBroadcasteris closed, invoking any other method on the broadcaster instance would result in anIllegalStateExceptionbeing thrown.- Specified by:
- closein interface- AutoCloseable
 
 
-