org.springframework.messaging.simp.config

## Class AbstractMessageBrokerConfiguration

- java.lang.Object
- - org.springframework.messaging.simp.config.AbstractMessageBrokerConfiguration

All Implemented Interfaces:
  org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

    public abstract class AbstractMessageBrokerConfiguration
    extends Object
    implements org.springframework.context.ApplicationContextAware

Provides essential configuration for handling messages with simple messaging protocols such as STOMP.

`clientInboundChannel()` and `clientOutboundChannel()` deliver messages to and from remote clients to several message handlers such as the following.

- `simpAnnotationMethodMessageHandler()`
- `simpleBrokerMessageHandler()`
- `stompBrokerRelayMessageHandler()`
- `userDestinationMessageHandler()`

`brokerChannel()` delivers messages from within the application to the the respective message handlers. `brokerMessagingTemplate()` can be injected into any application component to send messages.

Subclasses are responsible for the parts of the configuration that feed messages to and from the client inbound/outbound channels (e.g. STOMP over WebSocket).

Since:
  4.0
Author:
  Rossen Stoyanchev, Brian Clozel

### Constructor Summary

Constructors
`protected` `AbstractMessageBrokerConfiguration()` Protected constructor.

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods
`protected void` `addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers)`
`protected void` `addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers)`
`AbstractSubscribableChannel` `brokerChannel()`
`org.springframework.core.task.TaskExecutor` `brokerChannelExecutor()`
`CompositeMessageConverter` `brokerMessageConverter()`
`SimpMessagingTemplate` `brokerMessagingTemplate()`
`AbstractSubscribableChannel` `clientInboundChannel()`
`org.springframework.core.task.TaskExecutor` `clientInboundChannelExecutor()`
`AbstractSubscribableChannel` `clientOutboundChannel()`
`org.springframework.core.task.TaskExecutor` `clientOutboundChannelExecutor()`
`protected void` `configureClientInboundChannel(ChannelRegistration registration)` A hook for subclasses to customize the message channel for inbound messages from WebSocket clients.
`protected void` `configureClientOutboundChannel(ChannelRegistration registration)` A hook for subclasses to customize the message channel for messages from the application or message broker to WebSocket clients.
`protected void` `configureMessageBroker(MessageBrokerRegistry registry)` A hook for subclasses to customize message broker configuration through the provided `MessageBrokerRegistry` instance.
`protected boolean` `configureMessageConverters(List<MessageConverter> messageConverters)` Override this method to add custom message converters.
`protected SimpAnnotationMethodMessageHandler` `createAnnotationMethodMessageHandler()` Protected method for plugging in a custom subclass of `SimpAnnotationMethodMessageHandler`.
`protected MappingJackson2MessageConverter` `createJacksonConverter()`
`protected SimpUserRegistry` `createLocalUserRegistry()` Deprecated. as of 5.1 in favor of `createLocalUserRegistry(Integer)`
`protected abstract SimpUserRegistry` `createLocalUserRegistry(Integer order)` Create the user registry that provides access to local users.
`org.springframework.context.ApplicationContext` `getApplicationContext()`
`protected MessageBrokerRegistry` `getBrokerRegistry()` An accessor for the `MessageBrokerRegistry` that ensures its one-time creation and initialization through `configureMessageBroker(MessageBrokerRegistry)`.
`protected ChannelRegistration` `getClientInboundChannelRegistration()`
`protected ChannelRegistration` `getClientOutboundChannelRegistration()`
`org.springframework.util.PathMatcher` `getPathMatcher()` Provide access to the configured PatchMatcher for access from other configuration classes.
`org.springframework.validation.Validator` `getValidator()` Override this method to provide a custom `Validator`.
`org.springframework.scheduling.TaskScheduler` `messageBrokerTaskScheduler()`
`void` `setApplicationContext(org.springframework.context.ApplicationContext applicationContext)`
`SimpAnnotationMethodMessageHandler` `simpAnnotationMethodMessageHandler()`
`AbstractBrokerMessageHandler` `simpleBrokerMessageHandler()`
`protected org.springframework.validation.Validator` `simpValidator()` Return an `Validator` instance for validating `@Payload` method arguments.
`AbstractBrokerMessageHandler` `stompBrokerRelayMessageHandler()`
`UserDestinationMessageHandler` `userDestinationMessageHandler()`
`UserDestinationResolver` `userDestinationResolver()`
`SimpUserRegistry` `userRegistry()`
`MessageHandler` `userRegistryMessageHandler()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### AbstractMessageBrokerConfiguration

    protected AbstractMessageBrokerConfiguration()

Protected constructor.

### Method Detail

#### setApplicationContext

    public void setApplicationContext(@Nullable
                                      org.springframework.context.ApplicationContext applicationContext)

Specified by:
  `setApplicationContext` in interface `org.springframework.context.ApplicationContextAware`

#### getApplicationContext

    @Nullable
    public org.springframework.context.ApplicationContext getApplicationContext()

#### clientInboundChannel

    @Bean
    public AbstractSubscribableChannel clientInboundChannel()

#### clientInboundChannelExecutor

    @Bean
    public org.springframework.core.task.TaskExecutor clientInboundChannelExecutor()

#### getClientInboundChannelRegistration

    protected final ChannelRegistration getClientInboundChannelRegistration()

#### configureClientInboundChannel

    protected void configureClientInboundChannel(ChannelRegistration registration)

A hook for subclasses to customize the message channel for inbound messages from WebSocket clients.

#### clientOutboundChannel

    @Bean
    public AbstractSubscribableChannel clientOutboundChannel()

#### clientOutboundChannelExecutor

    @Bean
    public org.springframework.core.task.TaskExecutor clientOutboundChannelExecutor()

#### getClientOutboundChannelRegistration

    protected final ChannelRegistration getClientOutboundChannelRegistration()

#### configureClientOutboundChannel

    protected void configureClientOutboundChannel(ChannelRegistration registration)

A hook for subclasses to customize the message channel for messages from the application or message broker to WebSocket clients.

#### brokerChannel

    @Bean
    public AbstractSubscribableChannel brokerChannel()

#### brokerChannelExecutor

    @Bean
    public org.springframework.core.task.TaskExecutor brokerChannelExecutor()

#### getBrokerRegistry

    protected final MessageBrokerRegistry getBrokerRegistry()

An accessor for the `MessageBrokerRegistry` that ensures its one-time creation and initialization through `configureMessageBroker(MessageBrokerRegistry)`.

#### configureMessageBroker

    protected void configureMessageBroker(MessageBrokerRegistry registry)

A hook for subclasses to customize message broker configuration through the provided `MessageBrokerRegistry` instance.

#### getPathMatcher

    @Nullable
    public final org.springframework.util.PathMatcher getPathMatcher()

Provide access to the configured PatchMatcher for access from other configuration classes.

#### simpAnnotationMethodMessageHandler

    @Bean
    public SimpAnnotationMethodMessageHandler simpAnnotationMethodMessageHandler()

#### createAnnotationMethodMessageHandler

    protected SimpAnnotationMethodMessageHandler createAnnotationMethodMessageHandler()

Protected method for plugging in a custom subclass of `SimpAnnotationMethodMessageHandler`.

Since:
  4.2

#### addArgumentResolvers

    protected void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers)

#### addReturnValueHandlers

    protected void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers)

#### simpleBrokerMessageHandler

    @Bean
     @Nullable
    public AbstractBrokerMessageHandler simpleBrokerMessageHandler()

#### stompBrokerRelayMessageHandler

    @Bean
     @Nullable
    public AbstractBrokerMessageHandler stompBrokerRelayMessageHandler()

#### userDestinationMessageHandler

    @Bean
    public UserDestinationMessageHandler userDestinationMessageHandler()

#### userRegistryMessageHandler

    @Bean
     @Nullable
    public MessageHandler userRegistryMessageHandler()

#### messageBrokerTaskScheduler

    @Bean(name={"messageBrokerTaskScheduler","messageBrokerSockJsTaskScheduler"})
    public org.springframework.scheduling.TaskScheduler messageBrokerTaskScheduler()

#### brokerMessagingTemplate

    @Bean
    public SimpMessagingTemplate brokerMessagingTemplate()

#### brokerMessageConverter

    @Bean
    public CompositeMessageConverter brokerMessageConverter()

#### createJacksonConverter

    protected MappingJackson2MessageConverter createJacksonConverter()

#### configureMessageConverters

    protected boolean configureMessageConverters(List<MessageConverter> messageConverters)

Override this method to add custom message converters.

Parameters:
  `messageConverters` - the list to add converters to, initially empty
Returns:
  `true` if default message converters should be added to list, `false` if no more converters should be added

#### userDestinationResolver

    @Bean
    public UserDestinationResolver userDestinationResolver()

#### userRegistry

    @Bean
    public SimpUserRegistry userRegistry()

#### createLocalUserRegistry

    @Deprecated
     @Nullable
    protected SimpUserRegistry createLocalUserRegistry()

Deprecated. as of 5.1 in favor of `createLocalUserRegistry(Integer)`
Create the user registry that provides access to local users.

#### createLocalUserRegistry

    protected abstract SimpUserRegistry createLocalUserRegistry(@Nullable
                                                                Integer order)

Create the user registry that provides access to local users.

Parameters:
  `order` - the order to use as a `SmartApplicationListener`.
Since:
  5.1

#### simpValidator

    protected org.springframework.validation.Validator simpValidator()

Return an `Validator` instance for validating `@Payload` method arguments.

In order, this method tries to get a Validator instance:

- delegating to getValidator() first
- if none returned, getting an existing instance with its well-known name "mvcValidator", created by an MVC configuration
- if none returned, checking the classpath for the presence of a JSR-303 implementation before creating a `OptionalValidatorFactoryBean`
- returning a no-op Validator instance

#### getValidator

    @Nullable
    public org.springframework.validation.Validator getValidator()

Override this method to provide a custom `Validator`.

Since:
  4.0.1