I need to react on a user destination subscription.
A user subscribes to /user/messages
, because he wants to receive all incoming message
Define the user prefix also as an application prefix, and you'll then be able to map the subscription in your controller. Configuration:
@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
registry.setApplicationDestinationPrefixes("/app", "/user");
registry.enableSimpleBroker("/queue", "/topic");
registry.setUserDestinationPrefix("/user");
}
Controller:
@SubscribeMapping("/messages")
public void test(Principal p) {
sendMessagesThatWereReceivedWhileUserWasOffline();
}