Interface McpTaskEventPublisher
Events use broadcast rather than competing-consumer semantics: one listener
receiving an event must not consume it on behalf of the others.
Implementations may perform process-local delivery or coordinate through a
distributed service, and may provide best-effort rather than durable
delivery.
In a fleet, the application normally supplies a publisher that reaches every
Soklet node capable of serving the corresponding task. Soklet closes only
registrations returned by subscribe(McpTaskEventListener) and never
closes the publisher itself.
An event is a non-authoritative hint that carries only a task ID. It must be
published after the corresponding state change is durable and readable
through the associated McpTaskManager. Duplicate, delayed, or lost
events are permitted because polling remains authoritative. Soklet performs
a fresh manager lookup using each independently admitted subscription's
endpoint and identity before rendering a task snapshot. A publisher must
protect task IDs as potentially sensitive application data and must not
attach task state, principals, or authorization decisions to an event.
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull McpTaskEventPublisherCreates an independent in-memory publisher with default behavior.voidpublishTaskChanged(@NonNull String taskId) Broadcasts a coarse change event after the task's new durable state is readable through the associated task manager.subscribe(@NonNull McpTaskEventListener listener) Registers a listener for broadcast task-change events.
-
Method Details
-
fromInMemoryDefaults
Creates an independent in-memory publisher with default behavior.The publisher reaches only listeners registered with that instance in the current process and invokes them synchronously on the publishing thread. Closing a registration does not wait for a delivery already selected or in flight. If a listener throws a runtime exception, all other current listeners are still attempted before the first exception is rethrown with later exceptions suppressed.
- Returns:
- in-memory task-event publisher
-
subscribe
Registers a listener for broadcast task-change events.- Parameters:
listener- thread-safe listener- Returns:
- an idempotently closable listener registration
-
publishTaskChanged
Broadcasts a coarse change event after the task's new durable state is readable through the associated task manager.- Parameters:
taskId- changed task identifier- Throws:
NullPointerException- iftaskIdis nullIllegalArgumentException- iftaskIdis blank or contains a carriage-return or newline character
-