Package org.a2aproject.sdk.server.events
Class DefaultTaskStreamLifecycleHook
java.lang.Object
org.a2aproject.sdk.server.events.DefaultTaskStreamLifecycleHook
- All Implemented Interfaces:
TaskStreamLifecycleHook
@ApplicationScoped
public class DefaultTaskStreamLifecycleHook
extends Object
implements TaskStreamLifecycleHook
Default no-op implementation of
TaskStreamLifecycleHook.
Override with a CDI @Alternative @Priority bean to provide custom stream lifecycle behavior.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidonEvent(String taskId, Event event, StreamCloseHandle handle) Called after an event has been persisted and distributed to all ChildQueues.voidonSubscribe(String taskId, StreamCloseHandle handle) Called when a new ChildQueue is created for a task (a client subscribes to the stream).voidonUnsubscribe(String taskId, StreamCloseHandle handle) Called when a ChildQueue closes for a task (a client disconnects or streams are closed).
-
Constructor Details
-
DefaultTaskStreamLifecycleHook
public DefaultTaskStreamLifecycleHook()
-
-
Method Details
-
onSubscribe
Description copied from interface:TaskStreamLifecycleHookCalled when a new ChildQueue is created for a task (a client subscribes to the stream).If this method calls
StreamCloseHandle.closeStreams(), the ChildQueue being created will be closed beforetap()returns it to the caller. The caller will receive a closed queue whosedequeueEventItem()throwsEventQueueClosedExceptionimmediately.- Specified by:
onSubscribein interfaceTaskStreamLifecycleHook- Parameters:
taskId- the task identifierhandle- handle to close streams and query subscriber count
-
onUnsubscribe
Description copied from interface:TaskStreamLifecycleHookCalled when a ChildQueue closes for a task (a client disconnects or streams are closed).Calling
StreamCloseHandle.closeStreams()from within this callback is safe but has no effect — a reentrancy guard prevents recursive iteration over the children list. To close remaining streams in response to an unsubscription, schedule the call asynchronously or handle it inTaskStreamLifecycleHook.onEvent(java.lang.String, org.a2aproject.sdk.spec.Event, org.a2aproject.sdk.server.events.StreamCloseHandle).- Specified by:
onUnsubscribein interfaceTaskStreamLifecycleHook- Parameters:
taskId- the task identifierhandle- handle to close streams and query subscriber count
-
onEvent
Description copied from interface:TaskStreamLifecycleHookCalled after an event has been persisted and distributed to all ChildQueues.- Specified by:
onEventin interfaceTaskStreamLifecycleHook- Parameters:
taskId- the task identifierevent- the event that was processedhandle- handle to close streams and query subscriber count
-