- All Superinterfaces:
AutoCloseable
@Experimental
@NoImplement
@MinMuleVersion("4.10.0")
public interface SseSource
extends AutoCloseable
A consumer of server-sent events.
- Since:
- 0.12.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final int -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Aborts reconnection if it's scheduled, and closes the connection if established.voiddoOnConnectionFailure(Consumer<SseFailureContext> onConnectionFailure) Registers a callback to be called when an error occurs.intvoidopen()Opens the source.voidregister(String eventName, SseListener listener) Registers alistenerfor a specific event name (a.k.a. topic, a.k.a. type).voidregister(SseListener listener) Registers a fallbacklistenerfor all the events that aren't handled by any listener registered withregister(String, SseListener).
-
Field Details
-
READY_STATUS_CONNECTING
static final int READY_STATUS_CONNECTING- See Also:
-
READY_STATUS_OPEN
static final int READY_STATUS_OPEN- See Also:
-
READY_STATUS_CLOSED
static final int READY_STATUS_CLOSED- See Also:
-
-
Method Details
-
open
void open()Opens the source. It will send the initiator request or just start parsing the response's payload depending on the configuredSseSourceConfigurer. -
getReadyState
int getReadyState()- Returns:
- the readyState.
-
register
Registers alistenerfor a specific event name (a.k.a. topic, a.k.a. type).- Parameters:
eventName- The event name that thelistenerwill handle.listener- The event handler.
-
register
Registers a fallbacklistenerfor all the events that aren't handled by any listener registered withregister(String, SseListener).- Parameters:
listener- The event handler.
-
doOnConnectionFailure
Registers a callback to be called when an error occurs.- Parameters:
onConnectionFailure- to be called when an error occurs.
-
close
void close()Aborts reconnection if it's scheduled, and closes the connection if established.- Specified by:
closein interfaceAutoCloseable
-