Class InMemoryQueueManager

java.lang.Object
io.a2a.server.events.InMemoryQueueManager
All Implemented Interfaces:
QueueManager

@ApplicationScoped public class InMemoryQueueManager extends Object implements QueueManager
  • Constructor Details

  • Method Details

    • add

      public void add(String taskId, EventQueue queue)
      Specified by:
      add in interface QueueManager
    • get

      public EventQueue get(String taskId)
      Specified by:
      get in interface QueueManager
    • tap

      public EventQueue tap(String taskId)
      Specified by:
      tap in interface QueueManager
    • close

      public void close(String taskId)
      Specified by:
      close in interface QueueManager
    • createOrTap

      public EventQueue createOrTap(String taskId)
      Specified by:
      createOrTap in interface QueueManager
    • awaitQueuePollerStart

      public void awaitQueuePollerStart(EventQueue eventQueue) throws InterruptedException
      Specified by:
      awaitQueuePollerStart in interface QueueManager
      Throws:
      InterruptedException
    • getActiveChildQueueCount

      public int getActiveChildQueueCount(String taskId)
      Description copied from interface: QueueManager
      Get the count of active child queues for a given task. Used for testing to verify reference counting mechanism.
      Specified by:
      getActiveChildQueueCount in interface QueueManager
      Parameters:
      taskId - the task ID
      Returns:
      number of active child queues, or -1 if queue doesn't exist
    • getCleanupCallback

      public Runnable getCleanupCallback(String taskId)
      Get the cleanup callback that removes a queue from the map when it closes. This is exposed so that subclasses (like ReplicatedQueueManager) can reuse this cleanup logic while adding their own callbacks in the correct order.

      The cleanup callback checks if the task is finalized before removing the queue. If the task is not finalized, the queue remains in the map to handle late-arriving events.

      Parameters:
      taskId - the task ID for the queue
      Returns:
      a Runnable that removes the queue from the map if appropriate