Top Description Methods
org.springframework.web.socket.config.annotation

public Interface WebSocketMessageBrokerConfigurer

Imports
java.util.List, org.springframework.context.SmartLifecycle, org.springframework.lang.Nullable, org.springframework.messaging.converter.MessageConverter, org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver, .HandlerMethodReturnValueHandler, org.springframework.messaging.simp.config.ChannelRegistration, .MessageBrokerRegistry

Defines methods for configuring message handling with simple messaging protocols (e.g. STOMP) from WebSocket clients.

Typically used to customize the configuration provided via @EnableWebSocketMessageBroker.

Author
Rossen Stoyanchev
Since
4.0

Method Summary

Modifier and TypeMethod and Description
public default void
addArgumentResolvers(List<HandlerMethodArgumentResolver>
the resolvers to register (initially an empty list)
argumentResolvers
)

Add resolvers to support custom controller method argument types.

public default void
addReturnValueHandlers(List<HandlerMethodReturnValueHandler>
the handlers to register (initially an empty list)
returnValueHandlers
)

Add handlers to support custom controller method return value types.

public default void
configureClientInboundChannel(ChannelRegistration registration)

Configure the org.springframework.messaging.MessageChannel used for incoming messages from WebSocket clients.

public default void
configureClientOutboundChannel(ChannelRegistration registration)

Configure the org.springframework.messaging.MessageChannel used for outbound messages to WebSocket clients.

public default void
configureMessageBroker(MessageBrokerRegistry registry)

Configure message broker options.

public default boolean

Returns:

whether to also add default converter or not
configureMessageConverters
(List<MessageConverter>
the converters to configure (initially an empty list)
messageConverters
)

Configure the message converters to use when extracting the payload of messages in annotated methods and when sending messages (e.g. through the "broker" SimpMessagingTemplate).

public default void
configureWebSocketTransport(WebSocketTransportRegistration registry)

Configure options related to the processing of messages received from and sent to WebSocket clients.

public default Integer
getPhase()

Return the phase that WebSocket message handling beans of type SmartLifecycle should run in.

The default implementation returns null which allows other configurers to decide.

public default void
registerStompEndpoints(StompEndpointRegistry registry)

Register STOMP endpoints mapping each to a specific URL and (optionally) enabling and configuring SockJS fallback options.

Method Detail

addArgumentResolversback to summary
public default void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers)

Add resolvers to support custom controller method argument types.

This does not override the built-in support for resolving handler method arguments. To customize the built-in support for argument resolution, configure SimpAnnotationMethodMessageHandler directly.

Parameters
argumentResolvers:List<HandlerMethodArgumentResolver>

the resolvers to register (initially an empty list)

Since
4.1.1
addReturnValueHandlersback to summary
public default void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers)

Add handlers to support custom controller method return value types.

Using this option does not override the built-in support for handling return values. To customize the built-in support for handling return values, configure SimpAnnotationMethodMessageHandler directly.

Parameters
returnValueHandlers:List<HandlerMethodReturnValueHandler>

the handlers to register (initially an empty list)

Since
4.1.1
configureClientInboundChannelback to summary
public default void configureClientInboundChannel(ChannelRegistration registration)

Configure the org.springframework.messaging.MessageChannel used for incoming messages from WebSocket clients. By default, the channel is backed by a thread pool of size 1. It is recommended to customize thread pool settings for production use.

configureClientOutboundChannelback to summary
public default void configureClientOutboundChannel(ChannelRegistration registration)

Configure the org.springframework.messaging.MessageChannel used for outbound messages to WebSocket clients. By default, the channel is backed by a thread pool of size 1. It is recommended to customize thread pool settings for production use.

configureMessageBrokerback to summary
public default void configureMessageBroker(MessageBrokerRegistry registry)

Configure message broker options.

configureMessageConvertersback to summary
public default boolean configureMessageConverters(List<MessageConverter> messageConverters)

Configure the message converters to use when extracting the payload of messages in annotated methods and when sending messages (e.g. through the "broker" SimpMessagingTemplate).

The provided list, initially empty, can be used to add message converters while the boolean return value is used to determine if default message should be added as well.

Parameters
messageConverters:List<MessageConverter>

the converters to configure (initially an empty list)

Returns:boolean

whether to also add default converter or not

configureWebSocketTransportback to summary
public default void configureWebSocketTransport(WebSocketTransportRegistration registry)

Configure options related to the processing of messages received from and sent to WebSocket clients.

getPhaseback to summary
public default Integer getPhase()

Return the phase that WebSocket message handling beans of type SmartLifecycle should run in.

The default implementation returns null which allows other configurers to decide. As soon as any configurer returns a value, that value is used. If no configurer returns a value, then by default SmartLifecycle#DEFAULT_PHASE is used.

It is recommended to use a phase value such as 0 in order to ensure that components start before the web server in Spring Boot application. In 6.2.0, the default used will change to 0.

Annotations
@Nullable
Since
6.1.4
See Also
SmartLifecycle
registerStompEndpointsback to summary
public default void registerStompEndpoints(StompEndpointRegistry registry)

Register STOMP endpoints mapping each to a specific URL and (optionally) enabling and configuring SockJS fallback options.