Package com.yapcli.mcp.notifications
Class NotificationRouter
java.lang.Object
com.yapcli.mcp.notifications.NotificationRouter
- All Implemented Interfaces:
AutoCloseable,Consumer<com.fasterxml.jackson.databind.JsonNode>
public class NotificationRouter
extends Object
implements Consumer<com.fasterxml.jackson.databind.JsonNode>, AutoCloseable
路由 server → client 的通知到注册的 handler。
**关键约束**:handler 在独立 daemon executor 里执行,**不在 transport 的 stdout reader 线程里同步执行**。
否则 handler 内部如果要发 JSON-RPC 请求并等响应,自己等自己的响应,stdout reader 被阻塞读不到响应 → 死锁。
典型场景:server-everything 启动后立即推送 tools/list_changed,handler 调 tools/list 重拉,
stdout reader 线程被挂在 handler.apply 里,tools/list 响应进 buffer 但没人读,最终请求超时。
-
Constructor Details
-
NotificationRouter
public NotificationRouter()
-
-
Method Details
-
on
-
accept
public void accept(com.fasterxml.jackson.databind.JsonNode message) -
close
public void close()- Specified by:
closein interfaceAutoCloseable
-