Class SseUtils
java.lang.Object
com.mulesoft.connectors.a2a.internal.server.agent.utils.SseUtils
SSE-specific utility methods for handlers
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidbroadcastEvent(String taskId, String eventType, io.a2a.spec.StreamingEventKind streamingEvent, TaskRepository taskRepository, A2ASerializer a2ASerializer, SseClientRegistry sseClientRegistry) Broadcasts an SSE event to all clients for a specific taskstatic org.mule.runtime.http.api.sse.server.SseClientcreateSseConnection(RequestHandlerContext context, String taskId) Creates SSE connection and registers itstatic StringcreateStreamingResponse(String taskId, io.a2a.spec.StreamingEventKind streamingEvent, TaskRepository taskRepository) Creates a JSON-RPC success response for SSE eventsgetBufferedEvents(TaskRepository taskRepository, String taskId) Gets buffered events for a task, returns empty list if none foundstatic StringgetCurrentWorkerId(org.mule.runtime.core.api.MuleContext muleContext) Gets current worker instance ID from MuleContext.static voidhandleClientFailure(String taskId, org.mule.runtime.http.api.sse.server.SseClient sseClient, TaskRepository taskRepository, A2ASerializer a2ASerializer, SseClientRegistry sseClientRegistry) Handles client failure - sends failure event to the specific client.static booleanisCrossWorkerScenario(TaskRepositoryItem item, String currentWorkerId) Determines if the current event represents a cross-worker scenario.static voidreplayBufferedEventsToClient(List<TaskEvent> bufferedEvents, String taskId, org.mule.runtime.http.api.sse.server.SseClient sseClient, TaskRepository taskRepository, A2ASerializer a2ASerializer, SseClientRegistry sseClientRegistry) Sends buffered events to a specific SSE client (for resubscribe scenarios)
-
Constructor Details
-
SseUtils
public SseUtils()
-
-
Method Details
-
createStreamingResponse
public static String createStreamingResponse(String taskId, io.a2a.spec.StreamingEventKind streamingEvent, TaskRepository taskRepository) Creates a JSON-RPC success response for SSE events -
getBufferedEvents
public static List<TaskEvent> getBufferedEvents(TaskRepository taskRepository, String taskId) throws org.mule.runtime.api.store.ObjectStoreException Gets buffered events for a task, returns empty list if none found- Throws:
org.mule.runtime.api.store.ObjectStoreException
-
createSseConnection
public static org.mule.runtime.http.api.sse.server.SseClient createSseConnection(RequestHandlerContext context, String taskId) Creates SSE connection and registers it -
replayBufferedEventsToClient
public static void replayBufferedEventsToClient(List<TaskEvent> bufferedEvents, String taskId, org.mule.runtime.http.api.sse.server.SseClient sseClient, TaskRepository taskRepository, A2ASerializer a2ASerializer, SseClientRegistry sseClientRegistry) Sends buffered events to a specific SSE client (for resubscribe scenarios) -
broadcastEvent
public static void broadcastEvent(String taskId, String eventType, io.a2a.spec.StreamingEventKind streamingEvent, TaskRepository taskRepository, A2ASerializer a2ASerializer, SseClientRegistry sseClientRegistry) throws org.mule.runtime.extension.api.exception.ModuleException Broadcasts an SSE event to all clients for a specific task- Throws:
org.mule.runtime.extension.api.exception.ModuleException
-
handleClientFailure
public static void handleClientFailure(String taskId, org.mule.runtime.http.api.sse.server.SseClient sseClient, TaskRepository taskRepository, A2ASerializer a2ASerializer, SseClientRegistry sseClientRegistry) Handles client failure - sends failure event to the specific client. -
getCurrentWorkerId
Gets current worker instance ID from MuleContext. -
isCrossWorkerScenario
Determines if the current event represents a cross-worker scenario.
-