Does Spring @SubscribeMapping really subscribe the client to some topic?

后端 未结 5 788
别跟我提以往
别跟我提以往 2021-01-30 02:45

I am using Spring Websocket with STOMP, Simple Message Broker. In my @Controller I use method-level @SubscribeMapping, which should subscribe the clien

5条回答
  •  暖寄归人
    2021-01-30 02:58

    I faced with the same problem, and finally switched to solution when I subscribe to both /topic and /app on a client, buffering everything received on /topic handler until /app-bound one will download all the chat history, that is what @SubscribeMapping returns. Then I merge all recent chat entries with those received on a /topic - there could be duplicates in my case.

    Another working approach was to declare

    registry.enableSimpleBroker("/app", "/topic");
    registry.setApplicationDestinationPrefixes("/app", "/topic");
    

    Obviously, not perfect. But worked :)

提交回复
热议问题