@SubscriptionMapping for brokerage channel in Spring STOMP

Is the following Spring web socket configuration legal?

@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {

    @Override
    public void configureMessageBroker(MessageBrokerRegistry config) {
        config.enableSimpleBroker("/topic");
        config.setApplicationDestinationPrefixes("/topic" /* same as broker prefix */);
    }

    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) {
        registry.addEndpoint("/stomp");
    }

}

What I want to achieve is to intercept topic subscriptions in my @Controllerthrough @SubscribeMapping. However, for this I need the prefix to /topicbe defined as the application prefix. Reading the documentation and the JavaDoc gives the impression that this is incorrect (either the message must be processed by a broker or by application handlers). However, it works ... hence the question of whether this is a legal configuration.

+4
source share
1 answer

, , , , , .

@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
    config.enableSimpleBroker("/topic" /* This one is used for subscription*/);
    config.setApplicationDestinationPrefixes("/msg" /* this one is for sending messages */);
}
-1

Source: https://habr.com/ru/post/1609964/


All Articles