org.springframework.messaging.simp.config

## Class AbstractMessageBrokerConfiguration

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

- All Implemented Interfaces:
    Aware, ApplicationContextAware
  Direct Known Subclasses:
    WebSocketMessageBrokerConfigurationSupport

      public abstract class AbstractMessageBrokerConfiguration
      extends Object
      implements 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

  - `simpAnnotationMethodMessageHandler()`
  - `simpleBrokerMessageHandler()`
  - `stompBrokerRelayMessageHandler()`
  - `userDestinationMessageHandler()`
  while `brokerChannel()` delivers messages from within the application to the the respective message handlers. `brokerMessagingTemplate()` can be injected into any application component to send messages.

  Sub-classes are responsible for the part 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
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractMessageBrokerConfiguration()` Protected constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `AbstractSubscribableChannel` | `brokerChannel()`
    `ThreadPoolTaskExecutor` | `brokerChannelExecutor()`
    `CompositeMessageConverter` | `brokerMessageConverter()`
    `SimpMessagingTemplate` | `brokerMessagingTemplate()`
    `AbstractSubscribableChannel` | `clientInboundChannel()`
    `ThreadPoolTaskExecutor` | `clientInboundChannelExecutor()`
    `AbstractSubscribableChannel` | `clientOutboundChannel()`
    `ThreadPoolTaskExecutor` | `clientOutboundChannelExecutor()`
    `protected void` | `configureClientInboundChannel(ChannelRegistration registration)` A hook for sub-classes to customize the message channel for inbound messages from WebSocket clients.
    `protected void` | `configureClientOutboundChannel(ChannelRegistration registration)` A hook for sub-classes to customize the message channel for messages from the application or message broker to WebSocket clients.
    `protected void` | `configureMessageBroker(MessageBrokerRegistry registry)` A hook for sub-classes to customize message broker configuration through the provided `MessageBrokerRegistry` instance.
    `protected boolean` | `configureMessageConverters(List<MessageConverter> messageConverters)` Override this method to add custom message converters.
    `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()`
    `Validator` | `getValidator()` Override this method to provide a custom `Validator`.
    `void` | `setApplicationContext(ApplicationContext applicationContext)` Set the ApplicationContext that this object runs in.
    `SimpAnnotationMethodMessageHandler` | `simpAnnotationMethodMessageHandler()`
    `AbstractBrokerMessageHandler` | `simpleBrokerMessageHandler()`
    `protected Validator` | `simpValidator()` Return a `Validator`s instance for validating `@Payload` method arguments.
    `AbstractBrokerMessageHandler` | `stompBrokerRelayMessageHandler()`
    `UserDestinationMessageHandler` | `userDestinationMessageHandler()`
    `UserDestinationResolver` | `userDestinationResolver()`
    `UserSessionRegistry` | `userSessionRegistry()`

    - ### 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

    - #### clientInboundChannel

          @Bean
          public AbstractSubscribableChannel clientInboundChannel()

    - #### clientInboundChannelExecutor

          @Bean
          public ThreadPoolTaskExecutor clientInboundChannelExecutor()

    - #### getClientInboundChannelRegistration

          protected final ChannelRegistration getClientInboundChannelRegistration()

    - #### configureClientInboundChannel

          protected void configureClientInboundChannel(ChannelRegistration registration)

      A hook for sub-classes to customize the message channel for inbound messages from WebSocket clients.

    - #### clientOutboundChannel

          @Bean
          public AbstractSubscribableChannel clientOutboundChannel()

    - #### clientOutboundChannelExecutor

          @Bean
          public ThreadPoolTaskExecutor clientOutboundChannelExecutor()

    - #### getClientOutboundChannelRegistration

          protected final ChannelRegistration getClientOutboundChannelRegistration()

    - #### configureClientOutboundChannel

          protected void configureClientOutboundChannel(ChannelRegistration registration)

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

    - #### brokerChannel

          @Bean
          public AbstractSubscribableChannel brokerChannel()

    - #### brokerChannelExecutor

          @Bean
          public ThreadPoolTaskExecutor 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 sub-classes to customize message broker configuration through the provided `MessageBrokerRegistry` instance.

    - #### simpAnnotationMethodMessageHandler

          @Bean
          public SimpAnnotationMethodMessageHandler simpAnnotationMethodMessageHandler()

    - #### simpleBrokerMessageHandler

          @Bean
          public AbstractBrokerMessageHandler simpleBrokerMessageHandler()

    - #### stompBrokerRelayMessageHandler

          @Bean
          public AbstractBrokerMessageHandler stompBrokerRelayMessageHandler()

    - #### userDestinationMessageHandler

          @Bean
          public UserDestinationMessageHandler userDestinationMessageHandler()

    - #### brokerMessagingTemplate

          @Bean
          public SimpMessagingTemplate brokerMessagingTemplate()

    - #### brokerMessageConverter

          @Bean
          public CompositeMessageConverter brokerMessageConverter()

    - #### 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()

    - #### userSessionRegistry

          @Bean
          public UserSessionRegistry userSessionRegistry()

    - #### setApplicationContext

          public void setApplicationContext(ApplicationContext applicationContext)
                                     throws BeansException

      Description copied from interface: `ApplicationContextAware`
      Set the ApplicationContext that this object runs in. Normally this call will be used to initialize the object.

      Invoked after population of normal bean properties but before an init callback such as `InitializingBean.afterPropertiesSet()` or a custom init-method. Invoked after `ResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader)`, `ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)` and `MessageSourceAware`, if applicable.

      Specified by:
        `setApplicationContext` in interface `ApplicationContextAware`
      Parameters:
        `applicationContext` - the ApplicationContext object to be used by this object
      Throws:
        `ApplicationContextException` - in case of context initialization errors
        `BeansException` - if thrown by application context methods
      See Also:
        `BeanInitializationException`

    - #### getApplicationContext

          public ApplicationContext getApplicationContext()

    - #### simpValidator

          protected Validator simpValidator()

      Return a `Validator`s 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

          public Validator getValidator()

      Override this method to provide a custom `Validator`.
      Since:
        4.0.1