Interface McpSubscription
- All Superinterfaces:
AutoCloseable
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 TypeMethodDescriptionvoidclose()Closes this subscription: idempotent, deregisters from the broker that minted it, and interrupts a thread currently blocked intake().The honored filter this subscription was registered with.getId()The subscription identifier (the originatingsubscriptions/listenrequest's JSON-RPC id).booleanisClosed()Returns whether this subscription has been closed.take()Blocks until the next matching change event is available.
-
Method Details
-
getId
The subscription identifier (the originatingsubscriptions/listenrequest's JSON-RPC id).- Returns:
- The identifier. Never
nullor 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
InterruptedExceptionimmediately rather than blocking — load-bearing behavior for a pump's graceful-completion path, which relies on a closed-before-calledtake()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 concurrentclose(), or if this subscription was already closed before this call.
-
isClosed
boolean isClosed()Returns whether this subscription has been closed.- Returns:
trueif closed.
-
close
void close()Closes this subscription: idempotent, deregisters from the broker that minted it, and interrupts a thread currently blocked intake().- Specified by:
closein interfaceAutoCloseable
-