Class AbstractMessageBrokerConfiguration
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
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
ConstructorsModifierConstructorDescriptionprotectedProtected constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) protected voidaddReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) brokerChannel(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, org.springframework.core.task.TaskExecutor executor) org.springframework.core.task.TaskExecutorbrokerChannelExecutor(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel) brokerMessagingTemplate(AbstractSubscribableChannel brokerChannel, AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, CompositeMessageConverter brokerMessageConverter) clientInboundChannel(org.springframework.core.task.TaskExecutor executor) org.springframework.core.task.TaskExecutorclientOutboundChannel(org.springframework.core.task.TaskExecutor executor) org.springframework.core.task.TaskExecutorprotected voidconfigureClientInboundChannel(ChannelRegistration registration) A hook for subclasses to customize the message channel for inbound messages from WebSocket clients.protected voidconfigureClientOutboundChannel(ChannelRegistration registration) A hook for subclasses to customize the message channel for messages from the application or message broker to WebSocket clients.protected voidconfigureMessageBroker(MessageBrokerRegistry registry) A hook for subclasses to customize message broker configuration through the providedMessageBrokerRegistryinstance.protected booleanconfigureMessageConverters(List<MessageConverter> messageConverters) Override this method to add custom message converters.protected SimpAnnotationMethodMessageHandlercreateAnnotationMethodMessageHandler(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, SimpMessagingTemplate brokerMessagingTemplate) Protected method for plugging in a custom subclass ofSimpAnnotationMethodMessageHandler.protected MappingJackson2MessageConverterprotected abstract SimpUserRegistrycreateLocalUserRegistry(Integer order) Create the user registry that provides access to local users.org.springframework.context.ApplicationContextprotected final MessageBrokerRegistrygetBrokerRegistry(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel) An accessor for theMessageBrokerRegistrythat ensures its one-time creation and initialization throughconfigureMessageBroker(MessageBrokerRegistry).protected final ChannelRegistrationprotected final ChannelRegistrationfinal org.springframework.util.PathMatchergetPathMatcher(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel) Provide access to the configured PatchMatcher for access from other configuration classes.org.springframework.validation.ValidatorOverride this method to provide a customValidator.org.springframework.scheduling.TaskSchedulervoidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) simpAnnotationMethodMessageHandler(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, SimpMessagingTemplate brokerMessagingTemplate, CompositeMessageConverter brokerMessageConverter) simpleBrokerMessageHandler(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, AbstractSubscribableChannel brokerChannel, UserDestinationResolver userDestinationResolver) protected org.springframework.validation.ValidatorReturn anValidatorinstance for validating@Payloadmethod 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, org.springframework.scheduling.TaskScheduler scheduler)
-
Constructor Details
-
AbstractMessageBrokerConfiguration
protected AbstractMessageBrokerConfiguration()Protected constructor.
-
-
Method Details
-
setApplicationContext
public void setApplicationContext(@Nullable org.springframework.context.ApplicationContext applicationContext) - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware
-
getApplicationContext
@Nullable public org.springframework.context.ApplicationContext getApplicationContext() -
clientInboundChannel
@Bean public AbstractSubscribableChannel clientInboundChannel(@Qualifier("clientInboundChannelExecutor") org.springframework.core.task.TaskExecutor executor) -
clientInboundChannelExecutor
@Bean public org.springframework.core.task.TaskExecutor clientInboundChannelExecutor() -
getClientInboundChannelRegistration
-
configureClientInboundChannel
A hook for subclasses to customize the message channel for inbound messages from WebSocket clients. -
clientOutboundChannel
@Bean public AbstractSubscribableChannel clientOutboundChannel(@Qualifier("clientOutboundChannelExecutor") org.springframework.core.task.TaskExecutor executor) -
clientOutboundChannelExecutor
@Bean public org.springframework.core.task.TaskExecutor 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") org.springframework.core.task.TaskExecutor executor) -
brokerChannelExecutor
@Bean public org.springframework.core.task.TaskExecutor brokerChannelExecutor(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel) -
getBrokerRegistry
protected final MessageBrokerRegistry getBrokerRegistry(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel) An accessor for theMessageBrokerRegistrythat ensures its one-time creation and initialization throughconfigureMessageBroker(MessageBrokerRegistry). -
configureMessageBroker
A hook for subclasses to customize message broker configuration through the providedMessageBrokerRegistryinstance. -
getPathMatcher
@Nullable public final org.springframework.util.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") org.springframework.scheduling.TaskScheduler scheduler) -
messageBrokerTaskScheduler
@Bean(name={"messageBrokerTaskScheduler","messageBrokerSockJsTaskScheduler"}) public org.springframework.scheduling.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:
trueif default message converters should be added to list,falseif 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
protected org.springframework.validation.Validator simpValidator()Return anValidatorinstance for validating@Payloadmethod 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 customValidator.- Since:
- 4.0.1
-