public class MessageBrokerRegistry
extends java.lang.Object
Constructor and Description |
---|
MessageBrokerRegistry(SubscribableChannel clientInboundChannel,
MessageChannel clientOutboundChannel) |
Modifier and Type | Method and Description |
---|---|
ChannelRegistration |
configureBrokerChannel()
Customize the channel used to send messages from the application to the message
broker.
|
SimpleBrokerRegistration |
enableSimpleBroker(java.lang.String... destinationPrefixes)
Enable a simple message broker and configure one or more prefixes to filter
destinations targeting the broker (e.g.
|
StompBrokerRelayRegistration |
enableStompBrokerRelay(java.lang.String... destinationPrefixes)
Enable a STOMP broker relay and configure the destination prefixes supported by the
message broker.
|
protected java.util.Collection<java.lang.String> |
getApplicationDestinationPrefixes() |
protected ChannelRegistration |
getBrokerChannelRegistration() |
protected PathMatcher |
getPathMatcher() |
protected SimpleBrokerMessageHandler |
getSimpleBroker(SubscribableChannel brokerChannel) |
protected StompBrokerRelayMessageHandler |
getStompBrokerRelay(SubscribableChannel brokerChannel) |
protected java.lang.String |
getUserDestinationBroadcast() |
protected java.lang.String |
getUserDestinationPrefix() |
protected java.lang.String |
getUserRegistryBroadcast() |
protected java.lang.Integer |
getUserRegistryOrder() |
MessageBrokerRegistry |
setApplicationDestinationPrefixes(java.lang.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 |
setPreservePublishOrder(boolean preservePublishOrder)
Whether the client must receive messages in the order of publication.
|
MessageBrokerRegistry |
setUserDestinationPrefix(java.lang.String destinationPrefix)
Configure the prefix used to identify user destinations.
|
void |
setUserRegistryOrder(int order)
Set the order for the
SimpUserRegistry to use as a SmartApplicationListener . |
public MessageBrokerRegistry(SubscribableChannel clientInboundChannel, MessageChannel clientOutboundChannel)
public SimpleBrokerRegistration enableSimpleBroker(java.lang.String... destinationPrefixes)
public StompBrokerRelayRegistration enableStompBrokerRelay(java.lang.String... destinationPrefixes)
public ChannelRegistration configureBrokerChannel()
protected ChannelRegistration getBrokerChannelRegistration()
@Nullable protected java.lang.String getUserDestinationBroadcast()
@Nullable protected java.lang.String getUserRegistryBroadcast()
public MessageBrokerRegistry setApplicationDestinationPrefixes(java.lang.String... prefixes)
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.
@Nullable protected java.util.Collection<java.lang.String> getApplicationDestinationPrefixes()
public MessageBrokerRegistry setUserDestinationPrefix(java.lang.String destinationPrefix)
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/".
@Nullable protected java.lang.String getUserDestinationPrefix()
public void setUserRegistryOrder(int order)
SimpUserRegistry
to use as a SmartApplicationListener
.order
- the order value@Nullable protected java.lang.Integer getUserRegistryOrder()
public MessageBrokerRegistry setPathMatcher(PathMatcher pathMatcher)
@MessageMapping
and @SubscribeMapping
methods.
By default AntPathMatcher
is configured.
However applications may provide an AntPathMatcher
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.
DefaultSubscriptionRegistry.setPathMatcher(org.springframework.util.PathMatcher)
@Nullable protected PathMatcher getPathMatcher()
public MessageBrokerRegistry setCacheLimit(int cacheLimit)
This is currently only applied for the destination cache in the subscription registry. The default cache limit there is 1024.
DefaultSubscriptionRegistry.setCacheLimit(int)
public MessageBrokerRegistry setPreservePublishOrder(boolean preservePublishOrder)
By default messages sent to the "clientOutboundChannel"
may
not be processed in the same order because the channel is backed by a
ThreadPoolExecutor that in turn does not guarantee processing in order.
When this flag is set to true
messages within the same session
will be sent to the "clientOutboundChannel"
one at a time in
order to preserve the order of publication. Enable this only if needed
since there is some performance overhead to keep messages in order.
@Nullable protected SimpleBrokerMessageHandler getSimpleBroker(SubscribableChannel brokerChannel)
@Nullable protected StompBrokerRelayMessageHandler getStompBrokerRelay(SubscribableChannel brokerChannel)