Class AbstractMessageBrokerConfiguration
- All Implemented Interfaces:
Aware
,ApplicationContextAware
- Direct Known Subclasses:
WebSocketMessageBrokerConfigurationSupport
clientInboundChannel(org.springframework.core.task.TaskExecutor)
and clientOutboundChannel(org.springframework.core.task.TaskExecutor)
deliver
messages to and from remote clients to several message handlers such as the
following.
simpAnnotationMethodMessageHandler(org.springframework.messaging.support.AbstractSubscribableChannel, org.springframework.messaging.support.AbstractSubscribableChannel, org.springframework.messaging.simp.SimpMessagingTemplate, org.springframework.messaging.converter.CompositeMessageConverter)
simpleBrokerMessageHandler(org.springframework.messaging.support.AbstractSubscribableChannel, org.springframework.messaging.support.AbstractSubscribableChannel, org.springframework.messaging.support.AbstractSubscribableChannel, org.springframework.messaging.simp.user.UserDestinationResolver)
stompBrokerRelayMessageHandler(org.springframework.messaging.support.AbstractSubscribableChannel, org.springframework.messaging.support.AbstractSubscribableChannel, org.springframework.messaging.support.AbstractSubscribableChannel, org.springframework.messaging.simp.user.UserDestinationMessageHandler, org.springframework.messaging.MessageHandler, org.springframework.messaging.simp.user.UserDestinationResolver)
userDestinationMessageHandler(org.springframework.messaging.support.AbstractSubscribableChannel, org.springframework.messaging.support.AbstractSubscribableChannel, org.springframework.messaging.support.AbstractSubscribableChannel, org.springframework.messaging.simp.user.UserDestinationResolver)
brokerChannel(org.springframework.messaging.support.AbstractSubscribableChannel, org.springframework.messaging.support.AbstractSubscribableChannel, org.springframework.core.task.TaskExecutor)
delivers messages from within the application to the
respective message handlers. brokerMessagingTemplate(org.springframework.messaging.support.AbstractSubscribableChannel, org.springframework.messaging.support.AbstractSubscribableChannel, org.springframework.messaging.support.AbstractSubscribableChannel, org.springframework.messaging.converter.CompositeMessageConverter)
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, Sebastien Deleuze
-
Constructor Summary
ModifierConstructorDescriptionprotected
Protected constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addArgumentResolvers
(List<HandlerMethodArgumentResolver> argumentResolvers) protected void
addReturnValueHandlers
(List<HandlerMethodReturnValueHandler> returnValueHandlers) brokerChannel
(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, TaskExecutor executor) brokerChannelExecutor
(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel) brokerMessagingTemplate
(AbstractSubscribableChannel brokerChannel, AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, CompositeMessageConverter brokerMessageConverter) clientInboundChannel
(TaskExecutor executor) clientOutboundChannel
(TaskExecutor executor) 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 providedMessageBrokerRegistry
instance.protected boolean
configureMessageConverters
(List<MessageConverter> messageConverters) Override this method to add custom message converters.protected SimpAnnotationMethodMessageHandler
createAnnotationMethodMessageHandler
(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, SimpMessagingTemplate brokerMessagingTemplate) Protected method for plugging in a custom subclass ofSimpAnnotationMethodMessageHandler
.protected MappingJackson2MessageConverter
protected abstract SimpUserRegistry
createLocalUserRegistry
(Integer order) Create the user registry that provides access to local users.protected final MessageBrokerRegistry
getBrokerRegistry
(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel) An accessor for theMessageBrokerRegistry
that ensures its one-time creation and initialization throughconfigureMessageBroker(MessageBrokerRegistry)
.protected final ChannelRegistration
protected final ChannelRegistration
final PathMatcher
getPathMatcher
(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel) Provide access to the configured PatchMatcher for access from other configuration classes.protected final int
getPhase()
Override this method to provide a customValidator
.protected int
void
setApplicationContext
(ApplicationContext applicationContext) Set the ApplicationContext that this object runs in.simpAnnotationMethodMessageHandler
(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, SimpMessagingTemplate brokerMessagingTemplate, CompositeMessageConverter brokerMessageConverter) simpleBrokerMessageHandler
(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, AbstractSubscribableChannel brokerChannel, UserDestinationResolver userDestinationResolver) protected Validator
Return anValidator
instance for validating@Payload
method arguments.stompBrokerRelayMessageHandler
(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, AbstractSubscribableChannel brokerChannel, UserDestinationMessageHandler userDestinationMessageHandler, MessageHandler userRegistryMessageHandler, UserDestinationResolver userDestinationResolver) userDestinationMessageHandler
(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, AbstractSubscribableChannel brokerChannel, UserDestinationResolver userDestinationResolver) userDestinationResolver
(SimpUserRegistry userRegistry, AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel) userRegistry
(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel) userRegistryMessageHandler
(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, SimpUserRegistry userRegistry, SimpMessagingTemplate brokerMessagingTemplate, TaskScheduler scheduler)
-
Constructor Details
-
AbstractMessageBrokerConfiguration
protected AbstractMessageBrokerConfiguration()Protected constructor.
-
-
Method Details
-
setApplicationContext
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:
-
getApplicationContext
-
clientInboundChannel
@Bean public AbstractSubscribableChannel clientInboundChannel(@Qualifier("clientInboundChannelExecutor") TaskExecutor executor) -
clientInboundChannelExecutor
-
getClientInboundChannelRegistration
-
getPhase
protected final int getPhase() -
initPhase
protected int initPhase() -
configureClientInboundChannel
A hook for subclasses to customize the message channel for inbound messages from WebSocket clients. -
clientOutboundChannel
@Bean public AbstractSubscribableChannel clientOutboundChannel(@Qualifier("clientOutboundChannelExecutor") TaskExecutor executor) -
clientOutboundChannelExecutor
-
getClientOutboundChannelRegistration
-
configureClientOutboundChannel
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(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, @Qualifier("brokerChannelExecutor") TaskExecutor executor) -
brokerChannelExecutor
@Bean public TaskExecutor brokerChannelExecutor(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel) -
getBrokerRegistry
protected final MessageBrokerRegistry getBrokerRegistry(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel) An accessor for theMessageBrokerRegistry
that ensures its one-time creation and initialization throughconfigureMessageBroker(MessageBrokerRegistry)
. -
configureMessageBroker
A hook for subclasses to customize message broker configuration through the providedMessageBrokerRegistry
instance. -
getPathMatcher
@Nullable public final PathMatcher getPathMatcher(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel) Provide access to the configured PatchMatcher for access from other configuration classes. -
simpAnnotationMethodMessageHandler
@Bean public SimpAnnotationMethodMessageHandler simpAnnotationMethodMessageHandler(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, SimpMessagingTemplate brokerMessagingTemplate, CompositeMessageConverter brokerMessageConverter) -
createAnnotationMethodMessageHandler
protected SimpAnnotationMethodMessageHandler createAnnotationMethodMessageHandler(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, SimpMessagingTemplate brokerMessagingTemplate) Protected method for plugging in a custom subclass ofSimpAnnotationMethodMessageHandler
.- Since:
- 5.3.2
-
addArgumentResolvers
-
addReturnValueHandlers
-
simpleBrokerMessageHandler
@Bean @Nullable public AbstractBrokerMessageHandler simpleBrokerMessageHandler(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, AbstractSubscribableChannel brokerChannel, UserDestinationResolver userDestinationResolver) -
stompBrokerRelayMessageHandler
@Bean @Nullable public AbstractBrokerMessageHandler stompBrokerRelayMessageHandler(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, AbstractSubscribableChannel brokerChannel, UserDestinationMessageHandler userDestinationMessageHandler, @Nullable MessageHandler userRegistryMessageHandler, UserDestinationResolver userDestinationResolver) -
userDestinationMessageHandler
@Bean public UserDestinationMessageHandler userDestinationMessageHandler(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, AbstractSubscribableChannel brokerChannel, UserDestinationResolver userDestinationResolver) -
userRegistryMessageHandler
@Bean @Nullable public MessageHandler userRegistryMessageHandler(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, SimpUserRegistry userRegistry, SimpMessagingTemplate brokerMessagingTemplate, @Qualifier("messageBrokerTaskScheduler") TaskScheduler scheduler) -
messageBrokerTaskScheduler
@Bean(name={"messageBrokerTaskScheduler","messageBrokerSockJsTaskScheduler"}) public TaskScheduler messageBrokerTaskScheduler() -
brokerMessagingTemplate
@Bean public SimpMessagingTemplate brokerMessagingTemplate(AbstractSubscribableChannel brokerChannel, AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, CompositeMessageConverter brokerMessageConverter) -
brokerMessageConverter
-
createJacksonConverter
-
configureMessageConverters
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(SimpUserRegistry userRegistry, AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel) -
userRegistry
@Bean public SimpUserRegistry userRegistry(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel) -
createLocalUserRegistry
Create the user registry that provides access to local users.- Parameters:
order
- the order to use as aSmartApplicationListener
.- Since:
- 5.1
-
simpValidator
Return anValidator
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
Override this method to provide a customValidator
.- Since:
- 4.0.1
-