在Springboot中汇总STOMP广播端点路径

问题描述

我正在使用STOMP Websocket,并通过@SendToUser注释将广播消息限制为由Spring Security 5解析的特定用户:

@MessageMapping("/api/secure/autocomplete/username")
@SendToUser("/api/secure/broadcast")
public HttpEntity autocompleteUsername(AutocompleteQuery autocompleteQuery,Authentication authentication) throws Exception {
    ...
}

已经可以正常工作了。我想要的是自定义订阅的路径。要订阅上述消息,我们必须将/user附加到路径中,如下所示:

var stompClient = Stomp.over(socket);
stompClient.debug = null;
stompClient.connect({},function(frame) {
    stompClient.subscribe('/user/api/secure/broadcast',function(payload) {
        …
    }
}

如果您只想将消息发送回发给发送消息的人,则可以使用@SendToUser批注。但是请注意,要订阅这样的主题,您需要在该主题之前加上/user

来自Using WebSockets with Spring boot | Dimitri's tutorials

有没有办法将/user附加到主题路径?我希望它摆脱前缀,并希望它与@SendToUser批注中提供的一样。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...