SimpleBrokerMessageHandler

A "simple" message broker that recognizes the message types defined in {@link SimpMessageType}, keeps track of subscriptions with the help of a {@link SubscriptionRegistry} and sends messages to subscribers.

@author Rossen Stoyanchev @author Juergen Hoeller @since 4.0

Constructors

this
this(SubscribableChannel clientInboundChannel, MessageChannel clientOutboundChannel, SubscribableChannel brokerChannel, string[] destinationPrefixes)

Create a SimpleBrokerMessageHandler instance with the given message channels and destination prefixes. @param clientInboundChannel the channel for receiving messages from clients (e.g. WebSocket clients) @param clientOutboundChannel the channel for sending messages to clients (e.g. WebSocket clients) @param brokerChannel the channel for the application to send messages to the broker @param destinationPrefixes prefixes to use to filter out messages

Members

Functions

getHeaderInitializer
MessageHeaderInitializer getHeaderInitializer()

Return the configured header initializer. @since 4.1

getHeartbeatValue
long[] getHeartbeatValue()

The configured value for the heart-beat settings. @since 4.2

getSubscriptionRegistry
SubscriptionRegistry getSubscriptionRegistry()
Undocumented in source. Be warned that the author may not have intended to support it.
handleMessageInternal
void handleMessageInternal(MessageBase message)
Undocumented in source. Be warned that the author may not have intended to support it.
opCmp
int opCmp(MessageHandler o)
Undocumented in source. Be warned that the author may not have intended to support it.
sendMessageToSubscribers
void sendMessageToSubscribers(string destination, MessageBase message)
Undocumented in source. Be warned that the author may not have intended to support it.
setCacheLimit
void setCacheLimit(int cacheLimit)

When configured, the specified cache limit is passed down to the underlying SubscriptionRegistry, overriding any default there. <p>With a standard {@link DefaultSubscriptionRegistry}, the default cache limit is 1024. @since 4.3.2 @see #setSubscriptionRegistry @see DefaultSubscriptionRegistry#setCacheLimit @see DefaultSubscriptionRegistry#DEFAULT_CACHE_LIMIT

setHeaderInitializer
void setHeaderInitializer(MessageHeaderInitializer headerInitializer)

Configure a {@link MessageHeaderInitializer} to apply to the headers of all messages sent to the client outbound channel. <p>By default this property is not set. @since 4.1

setHeartbeatValue
void setHeartbeatValue(long[] heartbeat)

Configure the value for the heart-beat settings. The first number represents how often the server will write or send a heartbeat. The second is how often the client should write. 0 means no heartbeats. <p>By default this is set to "0, 0" unless the {@link #setTaskScheduler taskScheduler} in which case the default becomes "10000,10000" (in milliseconds). @since 4.2

setPathMatcher
void setPathMatcher(PathMatcher pathMatcher)

When configured, the given PathMatcher is passed down to the underlying SubscriptionRegistry to use for matching destination to subscriptions. <p>Default is a standard {@link hunt.framework.util.AntPathMatcher}. @since 4.1 @see #setSubscriptionRegistry @see DefaultSubscriptionRegistry#setPathMatcher @see hunt.framework.util.AntPathMatcher

setSelectorHeaderName
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. The header value is expected to be a Spring EL expression to be applied to the headers of messages matched to the subscription. <p>For example: <pre> headers.foo == 'bar' </pre> <p>By default this is set to "selector". You can set it to a different name, or to {@code null} to turn off support for a selector header. @param selectorHeaderName the name to use for a selector header @since 4.3.17 @see #setSubscriptionRegistry @see DefaultSubscriptionRegistry#setSelectorHeaderName(string)

setSubscriptionRegistry
void setSubscriptionRegistry(SubscriptionRegistry subscriptionRegistry)

Configure a custom SubscriptionRegistry to use for storing subscriptions. <p><strong>Note</strong> that when a custom PathMatcher is configured via {@link #setPathMatcher}, if the custom registry is not an instance of {@link DefaultSubscriptionRegistry}, the provided PathMatcher is not used and must be configured directly on the custom registry.

startInternal
void startInternal()
Undocumented in source. Be warned that the author may not have intended to support it.
stopInternal
void stopInternal()
Undocumented in source. Be warned that the author may not have intended to support it.
toString
string toString()
Undocumented in source. Be warned that the author may not have intended to support it.

Inherited Members

From AbstractBrokerMessageHandler

getClientInboundChannel
SubscribableChannel getClientInboundChannel()
Undocumented in source. Be warned that the author may not have intended to support it.
getClientOutboundChannel
MessageChannel getClientOutboundChannel()
Undocumented in source. Be warned that the author may not have intended to support it.
getBrokerChannel
SubscribableChannel getBrokerChannel()
Undocumented in source. Be warned that the author may not have intended to support it.
getDestinationPrefixes
string[] getDestinationPrefixes()
Undocumented in source. Be warned that the author may not have intended to support it.
setPreservePublishOrder
void setPreservePublishOrder(bool preservePublishOrder)

Whether the client must receive messages in the order of publication. <p>By default messages sent to the {@code "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. <p>When this flag is set to {@code true} messages within the same session will be sent to the {@code "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. @param preservePublishOrder whether to publish in order @since 5.1

isPreservePublishOrder
bool isPreservePublishOrder()

Whether to ensure messages are received in the order of publication. @since 5.1

setApplicationEventPublisher
void setApplicationEventPublisher(ApplicationEventPublisher publisher)
Undocumented in source. Be warned that the author may not have intended to support it.
getApplicationEventPublisher
ApplicationEventPublisher getApplicationEventPublisher()
Undocumented in source. Be warned that the author may not have intended to support it.
setAutoStartup
void setAutoStartup(bool autoStartup)
Undocumented in source. Be warned that the author may not have intended to support it.
isAutoStartup
bool isAutoStartup()
Undocumented in source. Be warned that the author may not have intended to support it.
getPhase
int getPhase()
Undocumented in source. Be warned that the author may not have intended to support it.
start
void start()
Undocumented in source. Be warned that the author may not have intended to support it.
startInternal
void startInternal()
Undocumented in source. Be warned that the author may not have intended to support it.
stop
void stop()
Undocumented in source. Be warned that the author may not have intended to support it.
stopInternal
void stopInternal()
Undocumented in source. Be warned that the author may not have intended to support it.
stop
void stop(Runnable callback)
Undocumented in source. Be warned that the author may not have intended to support it.
isRunning
bool isRunning()

Check whether this message handler is currently running. <p>Note that even when this message handler is running the {@link #isBrokerAvailable()} flag may still independently alternate between being on and off depending on the concrete sub-class implementation.

isBrokerAvailable
bool isBrokerAvailable()

Whether the message broker is currently available and able to process messages. <p>Note that this is in addition to the {@link #isRunning()} flag, which indicates whether this message handler is running. In other words the message handler must first be running and then the {@code #isBrokerAvailable()} flag may still independently alternate between being on and off depending on the concrete sub-class implementation. <p>Application components may implement {@code hunt.framework.context.ApplicationListener&lt;BrokerAvailabilityEvent&gt;} to receive notifications when broker becomes available and unavailable.

handleMessage
void handleMessage(MessageBase message)
Undocumented in source. Be warned that the author may not have intended to support it.
handleMessageInternal
void handleMessageInternal(MessageBase message)
Undocumented in source.
checkDestinationPrefix
bool checkDestinationPrefix(string destination)
Undocumented in source. Be warned that the author may not have intended to support it.
publishBrokerAvailableEvent
void publishBrokerAvailableEvent()
Undocumented in source. Be warned that the author may not have intended to support it.
publishBrokerUnavailableEvent
void publishBrokerUnavailableEvent()
Undocumented in source. Be warned that the author may not have intended to support it.
getClientOutboundChannelForSession
MessageChannel getClientOutboundChannelForSession(string sessionId)

Get the MessageChannel to use for sending messages to clients, possibly a per-session wrapper when {@code preservePublishOrder=true}. @since 5.1

Meta