Class DefaultSubscriptionRegistry
java.lang.Object
org.springframework.messaging.simp.broker.AbstractSubscriptionRegistry
org.springframework.messaging.simp.broker.DefaultSubscriptionRegistry
- All Implemented Interfaces:
- SubscriptionRegistry
Implementation of 
SubscriptionRegistry that stores subscriptions
 in memory and uses a PathMatcher
 for matching destinations.
 This class also supports an optional selector header on subscription messages with Spring Expression Language (SpEL) expressions evaluated against the headers to filter out messages in addition to destination matching. As of Spring Framework 6.1, the SpEL support is disabled by default, but it can be enabled by setting a selector header name.
- Since:
- 4.0
- Author:
- Rossen Stoyanchev, Sebastien Deleuze, Juergen Hoeller, Sam Brannen
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final intDefault maximum number of entries for the destination cache: 1024.Fields inherited from class org.springframework.messaging.simp.broker.AbstractSubscriptionRegistrylogger
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidaddSubscriptionInternal(String sessionId, String subscriptionId, String destination, Message<?> message) protected MultiValueMap<String,String> findSubscriptionsInternal(String destination, Message<?> message) intReturn the maximum number of entries for the resolved destination cache.Return the configuredPathMatcher.Return the name of the selector header.protected voidremoveSubscriptionInternal(String sessionId, String subscriptionId, Message<?> message) voidsetCacheLimit(int cacheLimit) Specify the maximum number of entries for the resolved destination cache.voidsetPathMatcher(PathMatcher pathMatcher) Specify thePathMatcherto use.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.voidunregisterAllSubscriptions(String sessionId) Remove all subscriptions associated with the given sessionId.Methods inherited from class org.springframework.messaging.simp.broker.AbstractSubscriptionRegistryfindSubscriptions, registerSubscription, unregisterSubscription
- 
Field Details- 
DEFAULT_CACHE_LIMITpublic static final int DEFAULT_CACHE_LIMITDefault maximum number of entries for the destination cache: 1024.- See Also:
 
 
- 
- 
Constructor Details- 
DefaultSubscriptionRegistrypublic DefaultSubscriptionRegistry()
 
- 
- 
Method Details- 
setPathMatcherSpecify thePathMatcherto use.
- 
getPathMatcherReturn the configuredPathMatcher.
- 
setCacheLimitpublic void setCacheLimit(int cacheLimit) Specify the maximum number of entries for the resolved destination cache. Default is 1024.
- 
getCacheLimitpublic int getCacheLimit()Return the maximum number of entries for the resolved destination cache.
- 
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.- Parameters:
- selectorHeaderName- the name to use for a selector header, or- nullor blank to disable selector header support
- Since:
- 4.2
 
- 
getSelectorHeaderNameReturn the name of the selector header.- Since:
- 4.2
- See Also:
 
- 
addSubscriptionInternalprotected void addSubscriptionInternal(String sessionId, String subscriptionId, String destination, Message<?> message) - Specified by:
- addSubscriptionInternalin class- AbstractSubscriptionRegistry
 
- 
removeSubscriptionInternalprotected void removeSubscriptionInternal(String sessionId, String subscriptionId, Message<?> message) - Specified by:
- removeSubscriptionInternalin class- AbstractSubscriptionRegistry
 
- 
unregisterAllSubscriptionsDescription copied from interface:SubscriptionRegistryRemove all subscriptions associated with the given sessionId.
- 
findSubscriptionsInternalprotected MultiValueMap<String,String> findSubscriptionsInternal(String destination, Message<?> message) - Specified by:
- findSubscriptionsInternalin class- AbstractSubscriptionRegistry
 
 
-