Class SimpleBrokerMessageHandler
- All Implemented Interfaces:
- Aware,- ApplicationEventPublisherAware,- Lifecycle,- Phased,- SmartLifecycle,- MessageHandler
SimpMessageType, keeps track of subscriptions with the help of a
 SubscriptionRegistry, and sends messages to subscribers.- Since:
- 4.0
- Author:
- Rossen Stoyanchev, Juergen Hoeller, Sam Brannen
- 
Field SummaryFields inherited from class org.springframework.messaging.simp.broker.AbstractBrokerMessageHandlerloggerFields inherited from interface org.springframework.context.SmartLifecycleDEFAULT_PHASE
- 
Constructor SummaryConstructorsConstructorDescriptionSimpleBrokerMessageHandler(SubscribableChannel clientInboundChannel, MessageChannel clientOutboundChannel, SubscribableChannel brokerChannel, Collection<String> destinationPrefixes) Create a SimpleBrokerMessageHandler instance with the given message channels and destination prefixes.
- 
Method SummaryModifier and TypeMethodDescriptionReturn the configured header initializer.long @Nullable []The configured value for the heart-beat settings.Return the configured TaskScheduler.protected voidhandleMessageInternal(Message<?> message) protected voidsendMessageToSubscribers(@Nullable String destination, Message<?> message) voidsetCacheLimit(@Nullable Integer cacheLimit) When configured, the specified cache limit is passed down to the underlying SubscriptionRegistry, overriding any default there.voidsetHeaderInitializer(@Nullable MessageHeaderInitializer headerInitializer) Configure aMessageHeaderInitializerto apply to the headers of all messages sent to the client outbound channel.voidsetHeartbeatValue(long @Nullable [] heartbeat) Configure the value for the heart-beat settings.voidsetPathMatcher(@Nullable PathMatcher pathMatcher) When configured, the given PathMatcher is passed down to the underlying SubscriptionRegistry to use for matching destination to subscriptions.voidsetSelectorHeaderName(@Nullable String selectorHeaderName) Configure the name of a header that a subscription message can have for the purpose of filtering messages matched to the subscription.voidsetSubscriptionRegistry(SubscriptionRegistry subscriptionRegistry) Configure a customSubscriptionRegistryto use for storing subscriptions.voidsetTaskScheduler(@Nullable TaskScheduler taskScheduler) Configure theTaskSchedulerto use for providing heartbeat support.voidvoidtoString()Methods inherited from class org.springframework.messaging.simp.broker.AbstractBrokerMessageHandlercheckDestinationPrefix, getApplicationEventPublisher, getBrokerChannel, getClientInboundChannel, getClientOutboundChannel, getClientOutboundChannelForSession, getDestinationPrefixes, getPhase, handleMessage, isAutoStartup, isBrokerAvailable, isPreservePublishOrder, isRunning, publishBrokerAvailableEvent, publishBrokerUnavailableEvent, setApplicationEventPublisher, setAutoStartup, setPhase, setPreservePublishOrder, setUserDestinationPredicate, start, stop, stop
- 
Constructor Details- 
SimpleBrokerMessageHandlerpublic SimpleBrokerMessageHandler(SubscribableChannel clientInboundChannel, MessageChannel clientOutboundChannel, SubscribableChannel brokerChannel, Collection<String> destinationPrefixes) Create a SimpleBrokerMessageHandler instance with the given message channels and destination prefixes.- Parameters:
- clientInboundChannel- the channel for receiving messages from clients (for example, WebSocket clients)
- clientOutboundChannel- the channel for sending messages to clients (for example, WebSocket clients)
- brokerChannel- the channel for the application to send messages to the broker
- destinationPrefixes- prefixes to use to filter out messages
 
 
- 
- 
Method Details- 
setSubscriptionRegistryConfigure a customSubscriptionRegistryto use for storing subscriptions.NOTE: If the custom registry is not an instance of DefaultSubscriptionRegistry, the configuredPathMatcher, cache limit, and selector header name are not used and must be configured directly on the custom registry.
- 
getSubscriptionRegistry
- 
setPathMatcherWhen configured, the given PathMatcher is passed down to the underlying SubscriptionRegistry to use for matching destination to subscriptions.Default is a standard AntPathMatcher.Setting this property has no effect if the underlying SubscriptionRegistry is not an instance of DefaultSubscriptionRegistry.- Since:
- 4.1
- See Also:
 
- 
setCacheLimitWhen configured, the specified cache limit is passed down to the underlying SubscriptionRegistry, overriding any default there.With a standard DefaultSubscriptionRegistry, the default cache limit is 1024.Setting this property has no effect if the underlying SubscriptionRegistry is not an instance of DefaultSubscriptionRegistry.- Since:
- 4.3.2
- See Also:
 
- 
setSelectorHeaderNameConfigure the name of a header that a subscription message can have for the purpose of filtering messages matched to the subscription.The header value is expected to be a Spring Expression Language (SpEL) boolean expression to be applied to the headers of messages matched to the subscription. For example: headers.foo == 'bar' By default the selector header name is set to nullwhich disables this feature. You can set it to"selector"or a different name to enable support for a selector header.Setting this property has no effect if the underlying SubscriptionRegistry is not an instance of DefaultSubscriptionRegistry.- Parameters:
- selectorHeaderName- the name to use for a selector header, or- nullor blank to disable selector header support
- Since:
- 4.3.17
- See Also:
 
- 
setTaskSchedulerConfigure theTaskSchedulerto use for providing heartbeat support. Setting this property also sets theheartbeatValueto "10000, 10000".By default this is not set. - Since:
- 4.2
 
- 
getTaskScheduler
- 
setHeartbeatValueConfigure the value for the heart-beat settings. The first number represents how often the server will write or send a heartbeat. The second is how often the client should write. 0 means no heartbeats.By default this is set to "0, 0" unless the taskSchedulerin which case the default becomes "10000,10000" (in milliseconds).- Since:
- 4.2
 
- 
getHeartbeatValueThe configured value for the heart-beat settings.- Since:
- 4.2
 
- 
setHeaderInitializerConfigure aMessageHeaderInitializerto apply to the headers of all messages sent to the client outbound channel.By default this property is not set. - Since:
- 4.1
 
- 
getHeaderInitializerReturn the configured header initializer.- Since:
- 4.1
 
- 
startInternalpublic void startInternal()- Overrides:
- startInternalin class- AbstractBrokerMessageHandler
 
- 
stopInternalpublic void stopInternal()- Overrides:
- stopInternalin class- AbstractBrokerMessageHandler
 
- 
handleMessageInternal- Specified by:
- handleMessageInternalin class- AbstractBrokerMessageHandler
 
- 
sendMessageToSubscribers
- 
toString
 
-