类 MessageBrokerRegistry
- java.lang.Object
- org.springframework.messaging.simp.config.MessageBrokerRegistry
public class MessageBrokerRegistry extends Object
A registry for configuring message broker options.- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev, Sebastien Deleuze
构造器概要
构造器 构造器 说明 MessageBrokerRegistry(SubscribableChannel clientInboundChannel, MessageChannel clientOutboundChannel)
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 ChannelRegistration
configureBrokerChannel()
Customize the channel used to send messages from the application to the message broker.SimpleBrokerRegistration
enableSimpleBroker(String... destinationPrefixes)
Enable a simple message broker and configure one or more prefixes to filter destinations targeting the broker (e.g. destinations prefixed with "/topic").StompBrokerRelayRegistration
enableStompBrokerRelay(String... destinationPrefixes)
Enable a STOMP broker relay and configure the destination prefixes supported by the message broker.protected Collection<String>
getApplicationDestinationPrefixes()
protected ChannelRegistration
getBrokerChannelRegistration()
protected PathMatcher
getPathMatcher()
protected SimpleBrokerMessageHandler
getSimpleBroker(SubscribableChannel brokerChannel)
protected StompBrokerRelayMessageHandler
getStompBrokerRelay(SubscribableChannel brokerChannel)
protected String
getUserDestinationBroadcast()
protected String
getUserDestinationPrefix()
protected String
getUserRegistryBroadcast()
MessageBrokerRegistry
setApplicationDestinationPrefixes(String... prefixes)
Configure one or more prefixes to filter destinations targeting application annotated methods.MessageBrokerRegistry
setCacheLimit(int cacheLimit)
Configure the cache limit to apply for registrations with the broker.MessageBrokerRegistry
setPathMatcher(PathMatcher pathMatcher)
Configure the PathMatcher to use to match the destinations of incoming messages to@MessageMapping
and@SubscribeMapping
methods.MessageBrokerRegistry
setUserDestinationPrefix(String destinationPrefix)
Configure the prefix used to identify user destinations.
构造器详细资料
MessageBrokerRegistry
public MessageBrokerRegistry(SubscribableChannel clientInboundChannel, MessageChannel clientOutboundChannel)
方法详细资料
enableSimpleBroker
public SimpleBrokerRegistration enableSimpleBroker(String... destinationPrefixes)
Enable a simple message broker and configure one or more prefixes to filter destinations targeting the broker (e.g. destinations prefixed with "/topic").
enableStompBrokerRelay
public StompBrokerRelayRegistration enableStompBrokerRelay(String... destinationPrefixes)
Enable a STOMP broker relay and configure the destination prefixes supported by the message broker. Check the STOMP documentation of the message broker for supported destinations.
configureBrokerChannel
public ChannelRegistration configureBrokerChannel()
Customize the channel used to send messages from the application to the message broker. By default, messages from the application to the message broker are sent synchronously, which means application code sending a message will find out if the message cannot be sent through an exception. However, this can be changed if the broker channel is configured here with task executor properties.
getBrokerChannelRegistration
protected ChannelRegistration getBrokerChannelRegistration()
getUserDestinationBroadcast
protected String getUserDestinationBroadcast()
getUserRegistryBroadcast
protected String getUserRegistryBroadcast()
setApplicationDestinationPrefixes
public MessageBrokerRegistry setApplicationDestinationPrefixes(String... prefixes)
Configure one or more prefixes to filter destinations targeting application annotated methods. For example destinations prefixed with "/app" may be processed by annotated methods while other destinations may target the message broker (e.g. "/topic", "/queue").When messages are processed, the matching prefix is removed from the destination in order to form the lookup path. This means annotations should not contain the destination prefix.
Prefixes that do not have a trailing slash will have one automatically appended.
getApplicationDestinationPrefixes
protected Collection<String> getApplicationDestinationPrefixes()
setUserDestinationPrefix
public MessageBrokerRegistry setUserDestinationPrefix(String destinationPrefix)
Configure the prefix used to identify user destinations. User destinations provide the ability for a user to subscribe to queue names unique to their session as well as for others to send messages to those unique, user-specific queues.For example when a user attempts to subscribe to "/user/queue/position-updates", the destination may be translated to "/queue/position-updatesi9oqdfzo" yielding a unique queue name that does not collide with any other user attempting to do the same. Subsequently when messages are sent to "/user/{username}/queue/position-updates", the destination is translated to "/queue/position-updatesi9oqdfzo".
The default prefix used to identify such destinations is "/user/".
getUserDestinationPrefix
protected String getUserDestinationPrefix()
setPathMatcher
public MessageBrokerRegistry setPathMatcher(PathMatcher pathMatcher)
Configure the PathMatcher to use to match the destinations of incoming messages to@MessageMapping
and@SubscribeMapping
methods.By default
AntPathMatcher
is configured. However applications may provide anAntPathMatcher
instance customized to use "." (commonly used in messaging) instead of "/" as path separator or provide a completely different PathMatcher implementation.Note that the configured PathMatcher is only used for matching the portion of the destination after the configured prefix. For example given application destination prefix "/app" and destination "/app/price.stock.**", the message might be mapped to a controller with "price" and "stock.**" as its type and method-level mappings respectively.
When the simple broker is enabled, the PathMatcher configured here is also used to match message destinations when brokering messages.
getPathMatcher
protected PathMatcher getPathMatcher()
setCacheLimit
public MessageBrokerRegistry setCacheLimit(int cacheLimit)
Configure the cache limit to apply for registrations with the broker.This is currently only applied for the destination cache in the subscription registry. The default cache limit there is 1024.
- 从以下版本开始:
- 4.3.2
- 另请参阅:
DefaultSubscriptionRegistry.setCacheLimit(int)
getSimpleBroker
protected SimpleBrokerMessageHandler getSimpleBroker(SubscribableChannel brokerChannel)
getStompBrokerRelay
protected StompBrokerRelayMessageHandler getStompBrokerRelay(SubscribableChannel brokerChannel)