org.springframework.messaging.simp.broker

## Class DefaultSubscriptionRegistry

- java.lang.Object
- - org.springframework.messaging.simp.broker.AbstractSubscriptionRegistry
  - - org.springframework.messaging.simp.broker.DefaultSubscriptionRegistry

All Implemented Interfaces:
  SubscriptionRegistry

    public class DefaultSubscriptionRegistry
    extends AbstractSubscriptionRegistry

Implementation of `SubscriptionRegistry` that stores subscriptions in memory and uses a `PathMatcher` for matching destinations.

As of 4.2, this class supports a `selector` header on subscription messages with Spring EL expressions evaluated against the headers to filter out messages in addition to destination matching.

Since:
  4.0
Author:
  Rossen Stoyanchev, Sebastien Deleuze, Juergen Hoeller

### Field Summary

Fields
`static int` `DEFAULT_CACHE_LIMIT` Default maximum number of entries for the destination cache: 1024.

### Fields inherited from class org.springframework.messaging.simp.broker.AbstractSubscriptionRegistry

`logger`

### Constructor Summary

Constructors
Constructor and Description
`DefaultSubscriptionRegistry()`

### Method Summary

All Methods Instance Methods Concrete Methods
`protected void` `addSubscriptionInternal(String sessionId, String subsId, String destination, Message<?> message)`
`protected org.springframework.util.MultiValueMap<String,String>` `findSubscriptionsInternal(String destination, Message<?> message)`
`int` `getCacheLimit()` Return the maximum number of entries for the resolved destination cache.
`org.springframework.util.PathMatcher` `getPathMatcher()` Return the configured `PathMatcher`.
`String` `getSelectorHeaderName()` Return the name for the selector header name.
`protected void` `removeSubscriptionInternal(String sessionId, String subsId, Message<?> message)`
`void` `setCacheLimit(int cacheLimit)` Specify the maximum number of entries for the resolved destination cache.
`void` `setPathMatcher(org.springframework.util.PathMatcher pathMatcher)` Specify the `PathMatcher` to use.
`void` `setSelectorHeaderName(String selectorHeaderName)` Configure the name of a header that a subscription message can have for the purpose of filtering messages matched to the subscription.
`String` `toString()`
`void` `unregisterAllSubscriptions(String sessionId)` Remove all subscriptions associated with the given sessionId.

### Methods inherited from class org.springframework.messaging.simp.broker.AbstractSubscriptionRegistry

`findSubscriptions, registerSubscription, unregisterSubscription`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### DEFAULT_CACHE_LIMIT

    public static final int DEFAULT_CACHE_LIMIT

Default maximum number of entries for the destination cache: 1024.

See Also:
  Constant Field Values

### Constructor Detail

#### DefaultSubscriptionRegistry

    public DefaultSubscriptionRegistry()

### Method Detail

#### setPathMatcher

    public void setPathMatcher(org.springframework.util.PathMatcher pathMatcher)

Specify the `PathMatcher` to use.

#### getPathMatcher

    public org.springframework.util.PathMatcher getPathMatcher()

Return the configured `PathMatcher`.

#### setCacheLimit

    public void setCacheLimit(int cacheLimit)

Specify the maximum number of entries for the resolved destination cache. Default is 1024.

#### getCacheLimit

    public int getCacheLimit()

Return the maximum number of entries for the resolved destination cache.

#### setSelectorHeaderName

    public void setSelectorHeaderName(@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. The header value is expected to be a Spring EL boolean expression to be applied to the headers of messages matched to the subscription.

For example:

     headers.foo == 'bar'

By default this is set to "selector". You can set it to a different name, or to `null` to turn off support for a selector header.

Parameters:
  `selectorHeaderName` - the name to use for a selector header
Since:
  4.2

#### getSelectorHeaderName

    @Nullable
    public String getSelectorHeaderName()

Return the name for the selector header name.

Since:
  4.2

#### addSubscriptionInternal

    protected void addSubscriptionInternal(String sessionId,
                                           String subsId,
                                           String destination,
                                           Message<?> message)

Specified by:
  `addSubscriptionInternal` in class `AbstractSubscriptionRegistry`

#### removeSubscriptionInternal

    protected void removeSubscriptionInternal(String sessionId,
                                              String subsId,
                                              Message<?> message)

Specified by:
  `removeSubscriptionInternal` in class `AbstractSubscriptionRegistry`

#### unregisterAllSubscriptions

    public void unregisterAllSubscriptions(String sessionId)

Description copied from interface: `SubscriptionRegistry`
Remove all subscriptions associated with the given sessionId.

#### findSubscriptionsInternal

    protected org.springframework.util.MultiValueMap<String,String> findSubscriptionsInternal(String destination,
                                                                                              Message<?> message)

Specified by:
  `findSubscriptionsInternal` in class `AbstractSubscriptionRegistry`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`