Class SseResponseWriter

java.lang.Object
org.a2aproject.sdk.server.common.quarkus.SseResponseWriter

public final class SseResponseWriter extends Object
Utility for writing SSE (Server-Sent Events) responses over Vert.x HTTP.

Events are requested all upfront (request(Long.MAX_VALUE)) so that back-to-back emissions from the EventConsumer are never dropped by a stalled single-item demand window. This means the EventConsumer's internal buffer (256 items) acts as the only bound — write-level backpressure is not applied. Ordering between the final response.write() and response.end() is preserved by EventConsumer.BUFFER_FLUSH_DELAY_MS: the EventConsumer waits briefly after sending the final event before calling tube.complete(), which ensures every write callback has confirmed delivery before onComplete is delivered to this subscriber.

  • Method Details

    • writeSseStrings

      public static void writeSseStrings(io.smallrye.mutiny.Multi<String> sseStrings, io.vertx.ext.web.RoutingContext rc, ServerCallContext context, @Nullable Runnable onSubscribedHook)
      Subscribes to sseStrings and writes each SSE event to the HTTP response.

      Error handling:

      • Client disconnect → cancels upstream, stops polling
      • Write failure → cancels upstream, fails routing context
      • Stream error → cancels upstream, fails routing context
      Parameters:
      sseStrings - the SSE-formatted event stream
      rc - the Vert.x routing context
      context - the A2A server call context (for EventConsumer cancellation)
      onSubscribedHook - optional hook invoked once the subscriber is attached; used by tests