Class AbstractSessionWebSocketMessageBrokerConfigurer<S extends Session>

java.lang.Object
org.springframework.session.web.socket.config.annotation.AbstractSessionWebSocketMessageBrokerConfigurer<S>
Type Parameters:
S - the type of Session
All Implemented Interfaces:
org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer

public abstract class AbstractSessionWebSocketMessageBrokerConfigurer<S extends Session> extends Object implements org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer
Eases configuration of Web Socket and Spring Session integration.

The configuration:

  • Ensures the Session is kept alive on incoming web socket messages.
  • Ensures that Web Socket Sessions are destroyed when a 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"); } }
Since:
1.0
  • Constructor Details

    • AbstractSessionWebSocketMessageBrokerConfigurer

      public AbstractSessionWebSocketMessageBrokerConfigurer()
  • Method Details

    • configureClientInboundChannel

      public void configureClientInboundChannel(org.springframework.messaging.simp.config.ChannelRegistration registration)
      Specified by:
      configureClientInboundChannel in interface org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer
    • registerStompEndpoints

      public final void registerStompEndpoints(org.springframework.web.socket.config.annotation.StompEndpointRegistry registry)
      Specified by:
      registerStompEndpoints in interface org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer
    • configureStompEndpoints

      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.
      Parameters:
      registry - the StompEndpointRegistry which automatically has a SessionRepositoryMessageInterceptor added to it.
    • configureWebSocketTransport

      public void configureWebSocketTransport(org.springframework.web.socket.config.annotation.WebSocketTransportRegistration registration)
      Specified by:
      configureWebSocketTransport in interface org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer
    • webSocketRegistryListener

      @Bean public WebSocketRegistryListener webSocketRegistryListener()
    • wsConnectHandlerDecoratorFactory

      @Bean public WebSocketConnectHandlerDecoratorFactory wsConnectHandlerDecoratorFactory()
    • sessionRepositoryInterceptor

      @Bean public SessionRepositoryMessageInterceptor<S> sessionRepositoryInterceptor()