Interface McpSubscription

All Superinterfaces:
AutoCloseable

public interface McpSubscription extends AutoCloseable
Per-subscription queue handle minted by an McpSubscriptionBroker.

Deliberately named differently from the client-facing McpSubscriptionHandle (a distinct type in a separate client module/package): this is the server-side, broker-internal handle a v2 dispatch branch drains via take() to serialize change events onto its own stream.

Owns its own bounded, drop-oldest queue — it does not reuse org.apache.juneau.rest.server.sse.SseSubscription, whose constructor and offer(...) method are package-private to a different package. Only one thread should call take() concurrently on a given instance (matching the production single-pump-per-subscription usage): close()'s contract of interrupting a blocked take() tracks a single in-flight taker thread.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes this subscription: idempotent, deregisters from the broker that minted it, and interrupts a thread currently blocked in take().
    The honored filter this subscription was registered with.
    The subscription identifier (the originating subscriptions/listen request's JSON-RPC id).
    boolean
    Returns whether this subscription has been closed.
    Blocks until the next matching change event is available.
  • Method Details

    • getId

      The subscription identifier (the originating subscriptions/listen request's JSON-RPC id).
      Returns:
      The identifier. Never null or empty.
    • getFilter

      The honored filter this subscription was registered with.
      Returns:
      The filter. Never null.
    • take

      Blocks until the next matching change event is available.

      Calling this on a subscription that is already closed throws InterruptedException immediately rather than blocking — load-bearing behavior for a pump's graceful-completion path, which relies on a closed-before-called take() failing fast instead of hanging forever waiting for an event that will never arrive.

      Returns:
      The next event.
      Throws:
      InterruptedException - If the wait was interrupted, including by a concurrent close(), or if this subscription was already closed before this call.
    • isClosed

      boolean isClosed()
      Returns whether this subscription has been closed.
      Returns:
      true if closed.
    • close

      void close()
      Closes this subscription: idempotent, deregisters from the broker that minted it, and interrupts a thread currently blocked in take().
      Specified by:
      close in interface AutoCloseable