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()
andclientOutboundChannel()
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 Modifier Constructor Description protected
AbstractMessageBrokerConfiguration()
Protected constructor.
Method Summary
Constructor Detail
AbstractMessageBrokerConfiguration
protected AbstractMessageBrokerConfiguration()
Protected constructor.
Method Detail
setApplicationContext
public void setApplicationContext(ApplicationContext applicationContext)
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 afterResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader)
,ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)
andMessageSourceAware
, if applicable.- Specified by:
setApplicationContext
in interfaceApplicationContextAware
- Parameters:
applicationContext
- the ApplicationContext object to be used by this object- See Also:
BeanInitializationException
getApplicationContext
public ApplicationContext getApplicationContext()
clientInboundChannel
@Bean public AbstractSubscribableChannel clientInboundChannel()
clientInboundChannelExecutor
@Bean public ThreadPoolTaskExecutor 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 ThreadPoolTaskExecutor 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 ThreadPoolTaskExecutor brokerChannelExecutor()
getBrokerRegistry
protected final MessageBrokerRegistry getBrokerRegistry()
An accessor for theMessageBrokerRegistry
that ensures its one-time creation and initialization throughconfigureMessageBroker(MessageBrokerRegistry)
.
configureMessageBroker
protected void configureMessageBroker(MessageBrokerRegistry registry)
A hook for subclasses to customize message broker configuration through the providedMessageBrokerRegistry
instance.
getPathMatcher
public final 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 ofSimpAnnotationMethodMessageHandler
.- Since:
- 4.2
addArgumentResolvers
protected void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers)
addReturnValueHandlers
protected void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers)
simpleBrokerMessageHandler
@Bean public AbstractBrokerMessageHandler simpleBrokerMessageHandler()
stompBrokerRelayMessageHandler
@Bean public AbstractBrokerMessageHandler stompBrokerRelayMessageHandler()
userDestinationMessageHandler
@Bean public UserDestinationMessageHandler userDestinationMessageHandler()
userRegistryMessageHandler
@Bean public MessageHandler userRegistryMessageHandler()
messageBrokerTaskScheduler
@Bean(name={"messageBrokerTaskScheduler","messageBrokerSockJsTaskScheduler"}) public ThreadPoolTaskScheduler 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
protected abstract SimpUserRegistry createLocalUserRegistry()
Create the user registry that provides access to local users.
userSessionRegistry
@Deprecated protected UserSessionRegistry userSessionRegistry()
Deprecated.As of 4.2,UserSessionRegistry
is deprecated in favor ofSimpUserRegistry
exposing information about all connected users. TheMultiServerUserRegistry
implementation in combination withUserRegistryMessageHandler
can be used to share user registries across multiple servers.
simpValidator
protected Validator simpValidator()
Return aValidator
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 customValidator
.- Since:
- 4.0.1