Interface McpSubscriptionHandle

All Superinterfaces:
AutoCloseable, Closeable

public interface McpSubscriptionHandle extends Closeable
Since:
10.0.0
  • Method Details

    • id

      The client-generated JSON-RPC request id this subscription's opening McpClient.listen(org.apache.juneau.bean.mcp.v20260728.SubscriptionFilter, McpSubscriptionListener) call sent, and which the server echoes back as the subscriptionId on every frame of this stream (the acknowledged frame, each change notification, and the terminal frame). Callers can use this to correlate this handle against server-side logs/traces for the same subscription.
      Returns:
      The request id. Never null or empty.
    • cancel

      void cancel()
      Cancels the subscription: signals the background pump to stop and closes the underlying stream. Idempotent.

      Asynchronous: this method returns as soon as the stop signal is issued and the stream close is requested, without waiting for the background pump thread to actually finish running. A caller that needs to know the pump has fully stopped must poll isOpen() or otherwise synchronize with it separately — this method does not join it.

    • close

      void close()
      Alias for cancel(), satisfying Closeable for try-with-resources use.

      Deliberately declares no checked IOException (narrows Closeable.close()'s throws clause) — the background pump owns the stream's lifecycle and closing it is always a local, non-throwing operation.

      Like cancel(), this is asynchronous: it signals the pump to stop but does not wait for it to exit.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • isOpen

      boolean isOpen()
      Returns:
      true if the subscription is still open (not cancelled, errored, or gracefully completed).