【发布时间】:2016-02-16 15:59:36
【问题描述】:
我正在阅读本书 Spring in Action 4 以通过 WebSocket 使用 STOMP 消息传递。
假设user destination prefix is set as "/user"如下:
registry.setUserDestinationPrefix("/user");
然后客户端使用以下 JavaScript 代码订阅目的地:
stomp.subscribe("/user/queue/notifications", handleNotifications);
然后在服务器上,the 客户端订阅的actual 目的地应该是从其会话派生,可能是这样的:
/queue/notifications-user6hr83v6t --- (1)
然后我使用SimpMessagingTemplate 向该用户发送消息:
messaging.convertAndSendToUser( username, "/queue/notifications",
new Notification("You just got mentioned!"));
然后消息将像这样发送到目的地:
/user/<username>/queue/notifications ---(2)
嗯,(1) 和 (2) 两个目的地看起来不同,消息怎么会到达客户端?
【问题讨论】: