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,
Collection<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.
|
SubscriptionRegistry |
getSubscriptionRegistry() |
protected void |
handleMessageInternal(Message<?> message) |
protected void |
sendMessageToSubscribers(String destination,
Message<?> message) |
void |
setHeaderInitializer(MessageHeaderInitializer headerInitializer)
Configure a
MessageHeaderInitializer to apply to the headers
of all messages sent to the client outbound channel. |
void |
setPathMatcher(PathMatcher pathMatcher)
When configured, the given PathMatcher is passed down to the
SubscriptionRegistry to use for matching destination to subscriptions.
|
void |
setSubscriptionRegistry(SubscriptionRegistry subscriptionRegistry)
Configure a custom SubscriptionRegistry to use for storing subscriptions.
|
void |
startInternal() |
void |
stopInternal() |
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, Collection<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)
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(String destination, Message<?> message)