Class StreamLifecycleClient

java.lang.Object
org.a2aproject.sdk.examples.streamlifecycle.client.StreamLifecycleClient

public class StreamLifecycleClient extends Object
Demonstrates the TaskStreamLifecycleHook by connecting 3 subscribers to a task.

Flow:

  1. Subscriber 1: sends a message (creates the task, starts streaming)
  2. Subscriber 2: subscribes to the same task
  3. Both subscribers receive progress messages from the agent
  4. Subscriber 3: subscribes — the server hook detects 3 subscribers and closes all streams
  5. All subscribers see their streams end gracefully

Start the server first (mvn quarkus:dev in the server module), then run this client.

This class also serves as the integration test body — runAndVerify(AgentCard, String) is called by the server module's @QuarkusTest for each transport protocol.

  • Constructor Details

    • StreamLifecycleClient

      public StreamLifecycleClient()
  • Method Details

    • main

      public static void main(String[] args) throws Exception
      Throws:
      Exception
    • runAndVerify

      public static void runAndVerify(AgentCard agentCard, String protocol) throws Exception
      Runs the 3-subscriber scenario and asserts correctness. Called by main() for manual runs and by the server's @QuarkusTest for each protocol.
      Throws:
      Exception
    • shutdownGrpcChannels

      public static void shutdownGrpcChannels()
    • logEvent

      public static void logEvent(String subscriber, ClientEvent event)