public abstract class AbstractMessageBrokerConfiguration extends Object implements 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).
Modifier | Constructor and Description |
---|---|
protected |
AbstractMessageBrokerConfiguration()
Protected constructor.
|
protected AbstractMessageBrokerConfiguration()
public void setApplicationContext(@Nullable ApplicationContext applicationContext)
ApplicationContextAware
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.
setApplicationContext
in interface ApplicationContextAware
applicationContext
- the ApplicationContext object to be used by this objectBeanInitializationException
@Nullable public ApplicationContext getApplicationContext()
@Bean public AbstractSubscribableChannel clientInboundChannel(@Qualifier(value="clientInboundChannelExecutor") TaskExecutor executor)
@Bean public TaskExecutor clientInboundChannelExecutor()
protected final ChannelRegistration getClientInboundChannelRegistration()
protected void configureClientInboundChannel(ChannelRegistration registration)
@Bean public AbstractSubscribableChannel clientOutboundChannel(@Qualifier(value="clientOutboundChannelExecutor") TaskExecutor executor)
@Bean public TaskExecutor clientOutboundChannelExecutor()
protected final ChannelRegistration getClientOutboundChannelRegistration()
protected void configureClientOutboundChannel(ChannelRegistration registration)
@Bean public AbstractSubscribableChannel brokerChannel(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, @Qualifier(value="brokerChannelExecutor") TaskExecutor executor)
@Bean public TaskExecutor brokerChannelExecutor(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel)
protected final MessageBrokerRegistry getBrokerRegistry(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel)
MessageBrokerRegistry
that ensures its one-time creation
and initialization through configureMessageBroker(MessageBrokerRegistry)
.protected void configureMessageBroker(MessageBrokerRegistry registry)
MessageBrokerRegistry
instance.@Nullable public final PathMatcher getPathMatcher(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel)
@Bean public SimpAnnotationMethodMessageHandler simpAnnotationMethodMessageHandler(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, SimpMessagingTemplate brokerMessagingTemplate, CompositeMessageConverter brokerMessageConverter)
protected SimpAnnotationMethodMessageHandler createAnnotationMethodMessageHandler(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, SimpMessagingTemplate brokerMessagingTemplate)
SimpAnnotationMethodMessageHandler
.protected void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers)
protected void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers)
@Bean @Nullable public AbstractBrokerMessageHandler simpleBrokerMessageHandler(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, AbstractSubscribableChannel brokerChannel, UserDestinationResolver userDestinationResolver)
@Bean @Nullable public AbstractBrokerMessageHandler stompBrokerRelayMessageHandler(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, AbstractSubscribableChannel brokerChannel, UserDestinationMessageHandler userDestinationMessageHandler, @Nullable MessageHandler userRegistryMessageHandler, UserDestinationResolver userDestinationResolver)
@Bean public UserDestinationMessageHandler userDestinationMessageHandler(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, AbstractSubscribableChannel brokerChannel, UserDestinationResolver userDestinationResolver)
@Bean @Nullable public MessageHandler userRegistryMessageHandler(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, SimpUserRegistry userRegistry, SimpMessagingTemplate brokerMessagingTemplate, @Qualifier(value="messageBrokerTaskScheduler") TaskScheduler scheduler)
@Bean(name={"messageBrokerTaskScheduler","messageBrokerSockJsTaskScheduler"}) public TaskScheduler messageBrokerTaskScheduler()
@Bean public SimpMessagingTemplate brokerMessagingTemplate(AbstractSubscribableChannel brokerChannel, AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel, CompositeMessageConverter brokerMessageConverter)
@Bean public CompositeMessageConverter brokerMessageConverter()
protected MappingJackson2MessageConverter createJacksonConverter()
protected boolean configureMessageConverters(List<MessageConverter> messageConverters)
messageConverters
- the list to add converters to, initially emptytrue
if default message converters should be added to list,
false
if no more converters should be added@Bean public UserDestinationResolver userDestinationResolver(SimpUserRegistry userRegistry, AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel)
@Bean public SimpUserRegistry userRegistry(AbstractSubscribableChannel clientInboundChannel, AbstractSubscribableChannel clientOutboundChannel)
@Deprecated @Nullable protected SimpUserRegistry createLocalUserRegistry()
createLocalUserRegistry(Integer)
protected abstract SimpUserRegistry createLocalUserRegistry(@Nullable Integer order)
order
- the order to use as a SmartApplicationListener
.protected Validator simpValidator()
Validator
instance for
validating @Payload
method arguments.
In order, this method tries to get a Validator instance:
OptionalValidatorFactoryBean