S
- the type of Sessionpublic abstract class AbstractSessionWebSocketMessageBrokerConfigurer<S extends Session>
extends java.lang.Object
implements org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer
The configuration:
Session
is kept alive on incoming web socket messages.Session
is terminated
Example usage
@Configuration
@EnableScheduling
@EnableWebSocketMessageBroker
public class WebSocketConfig<S extends Session> extends AbstractSessionWebSocketMessageBrokerConfigurer<S> {
@Override
protected void configureStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/messages")
.withSockJS();
}
@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
registry.enableSimpleBroker("/queue/", "/topic/");
registry.setApplicationDestinationPrefixes("/app");
}
}
Constructor and Description |
---|
AbstractSessionWebSocketMessageBrokerConfigurer() |
Modifier and Type | Method and Description |
---|---|
void |
configureClientInboundChannel(org.springframework.messaging.simp.config.ChannelRegistration registration) |
protected abstract void |
configureStompEndpoints(org.springframework.web.socket.config.annotation.StompEndpointRegistry registry)
Register STOMP endpoints mapping each to a specific URL and (optionally) enabling
and configuring SockJS fallback options with a
SessionRepositoryMessageInterceptor automatically added as an interceptor. |
void |
configureWebSocketTransport(org.springframework.web.socket.config.annotation.WebSocketTransportRegistration registration) |
void |
registerStompEndpoints(org.springframework.web.socket.config.annotation.StompEndpointRegistry registry) |
SessionRepositoryMessageInterceptor<S> |
sessionRepositoryInterceptor() |
WebSocketRegistryListener |
webSocketRegistryListener() |
WebSocketConnectHandlerDecoratorFactory |
wsConnectHandlerDecoratorFactory() |
public AbstractSessionWebSocketMessageBrokerConfigurer()
public void configureClientInboundChannel(org.springframework.messaging.simp.config.ChannelRegistration registration)
configureClientInboundChannel
in interface org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer
public final void registerStompEndpoints(org.springframework.web.socket.config.annotation.StompEndpointRegistry registry)
registerStompEndpoints
in interface org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer
protected abstract void configureStompEndpoints(org.springframework.web.socket.config.annotation.StompEndpointRegistry registry)
SessionRepositoryMessageInterceptor
automatically added as an interceptor.registry
- the StompEndpointRegistry
which automatically has a
SessionRepositoryMessageInterceptor
added to it.public void configureWebSocketTransport(org.springframework.web.socket.config.annotation.WebSocketTransportRegistration registration)
configureWebSocketTransport
in interface org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer
@Bean public WebSocketRegistryListener webSocketRegistryListener()
@Bean public WebSocketConnectHandlerDecoratorFactory wsConnectHandlerDecoratorFactory()
@Bean public SessionRepositoryMessageInterceptor<S> sessionRepositoryInterceptor()