public class SimpleBrokerMessageHandler extends AbstractBrokerMessageHandler
SimpMessageType
, keeps track of subscriptions with the help of a
SubscriptionRegistry
and sends messages to subscribers.logger
Constructor and Description |
---|
SimpleBrokerMessageHandler(SubscribableChannel clientInboundChannel,
MessageChannel clientOutboundChannel,
SubscribableChannel brokerChannel,
java.util.Collection<java.lang.String> destinationPrefixes)
Create a SimpleBrokerMessageHandler instance with the given message channels
and destination prefixes.
|
Modifier and Type | Method and Description |
---|---|
MessageHeaderInitializer |
getHeaderInitializer()
Return the configured header initializer.
|
long[] |
getHeartbeatValue()
The configured value for the heart-beat settings.
|
SubscriptionRegistry |
getSubscriptionRegistry() |
TaskScheduler |
getTaskScheduler()
Return the configured TaskScheduler.
|
protected void |
handleMessageInternal(Message<?> message) |
protected void |
sendMessageToSubscribers(java.lang.String destination,
Message<?> message) |
void |
setCacheLimit(java.lang.Integer cacheLimit)
When configured, the specified cache limit is passed down to the
underlying SubscriptionRegistry, overriding any default there.
|
void |
setHeaderInitializer(MessageHeaderInitializer headerInitializer)
Configure a
MessageHeaderInitializer to apply to the headers
of all messages sent to the client outbound channel. |
void |
setHeartbeatValue(long[] heartbeat)
Configure the value for the heart-beat settings.
|
void |
setPathMatcher(PathMatcher pathMatcher)
When configured, the given PathMatcher is passed down to the underlying
SubscriptionRegistry to use for matching destination to subscriptions.
|
void |
setSubscriptionRegistry(SubscriptionRegistry subscriptionRegistry)
Configure a custom SubscriptionRegistry to use for storing subscriptions.
|
void |
setTaskScheduler(TaskScheduler taskScheduler)
Configure the
TaskScheduler to
use for providing heartbeat support. |
void |
startInternal() |
void |
stopInternal() |
java.lang.String |
toString() |
checkDestinationPrefix, getApplicationEventPublisher, getBrokerChannel, getClientInboundChannel, getClientOutboundChannel, getDestinationPrefixes, getPhase, handleMessage, isAutoStartup, isBrokerAvailable, isRunning, publishBrokerAvailableEvent, publishBrokerUnavailableEvent, setApplicationEventPublisher, setAutoStartup, start, stop, stop
public SimpleBrokerMessageHandler(SubscribableChannel clientInboundChannel, MessageChannel clientOutboundChannel, SubscribableChannel brokerChannel, java.util.Collection<java.lang.String> destinationPrefixes)
clientInboundChannel
- the channel for receiving messages from clients (e.g. WebSocket clients)clientOutboundChannel
- the channel for sending messages to clients (e.g. WebSocket clients)brokerChannel
- the channel for the application to send messages to the brokerdestinationPrefixes
- prefixes to use to filter out messagespublic void setSubscriptionRegistry(SubscriptionRegistry subscriptionRegistry)
Note that when a custom PathMatcher is configured via
setPathMatcher(org.springframework.util.PathMatcher)
, if the custom registry is not an instance of
DefaultSubscriptionRegistry
, the provided PathMatcher is not used
and must be configured directly on the custom registry.
public SubscriptionRegistry getSubscriptionRegistry()
public void setPathMatcher(PathMatcher pathMatcher)
Default is a standard AntPathMatcher
.
public void setCacheLimit(java.lang.Integer cacheLimit)
With a standard DefaultSubscriptionRegistry
, the default
cache limit is 1024.
public void setTaskScheduler(TaskScheduler taskScheduler)
TaskScheduler
to
use for providing heartbeat support. Setting this property also sets the
heartbeatValue
to "10000, 10000".
By default this is not set.
public TaskScheduler getTaskScheduler()
public void setHeartbeatValue(long[] heartbeat)
By default this is set to "0, 0" unless the taskScheduler
in which case the default becomes "10000,10000"
(in milliseconds).
public long[] getHeartbeatValue()
public void setHeaderInitializer(MessageHeaderInitializer headerInitializer)
MessageHeaderInitializer
to apply to the headers
of all messages sent to the client outbound channel.
By default this property is not set.
public MessageHeaderInitializer getHeaderInitializer()
public void startInternal()
startInternal
in class AbstractBrokerMessageHandler
public void stopInternal()
stopInternal
in class AbstractBrokerMessageHandler
protected void handleMessageInternal(Message<?> message)
handleMessageInternal
in class AbstractBrokerMessageHandler
protected void sendMessageToSubscribers(java.lang.String destination, Message<?> message)
public java.lang.String toString()
toString
in class java.lang.Object