类 SimpleBrokerMessageHandler
- java.lang.Object
- org.springframework.messaging.simp.broker.AbstractBrokerMessageHandler
- org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler
public class SimpleBrokerMessageHandler extends AbstractBrokerMessageHandler
A "simple" message broker that recognizes the message types defined inSimpMessageType
, keeps track of subscriptions with the help of aSubscriptionRegistry
and sends messages to subscribers.- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev, Juergen Hoeller
字段概要
从类继承的字段 org.springframework.messaging.simp.broker.AbstractBrokerMessageHandler
logger
构造器概要
构造器 构造器 说明 SimpleBrokerMessageHandler(SubscribableChannel clientInboundChannel, MessageChannel clientOutboundChannel, SubscribableChannel brokerChannel, Collection<String> destinationPrefixes)
Create a SimpleBrokerMessageHandler instance with the given message channels and destination prefixes.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 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(String destination, Message<?> message)
void
setCacheLimit(Integer cacheLimit)
When configured, the specified cache limit is passed down to the underlying SubscriptionRegistry, overriding any default there.void
setHeaderInitializer(MessageHeaderInitializer headerInitializer)
Configure aMessageHeaderInitializer
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
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.void
setSubscriptionRegistry(SubscriptionRegistry subscriptionRegistry)
Configure a custom SubscriptionRegistry to use for storing subscriptions.void
setTaskScheduler(TaskScheduler taskScheduler)
Configure theTaskScheduler
to use for providing heartbeat support.void
startInternal()
void
stopInternal()
String
toString()
从类继承的方法 org.springframework.messaging.simp.broker.AbstractBrokerMessageHandler
checkDestinationPrefix, getApplicationEventPublisher, getBrokerChannel, getClientInboundChannel, getClientOutboundChannel, getDestinationPrefixes, getPhase, handleMessage, isAutoStartup, isBrokerAvailable, isRunning, publishBrokerAvailableEvent, publishBrokerUnavailableEvent, setApplicationEventPublisher, setAutoStartup, start, stop, stop
构造器详细资料
SimpleBrokerMessageHandler
public SimpleBrokerMessageHandler(SubscribableChannel clientInboundChannel, MessageChannel clientOutboundChannel, SubscribableChannel brokerChannel, Collection<String> destinationPrefixes)
Create a SimpleBrokerMessageHandler instance with the given message channels and destination prefixes.- 参数:
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 messages
方法详细资料
setSubscriptionRegistry
public void setSubscriptionRegistry(SubscriptionRegistry subscriptionRegistry)
Configure a custom SubscriptionRegistry to use for storing subscriptions.Note that when a custom PathMatcher is configured via
setPathMatcher(org.springframework.util.PathMatcher)
, if the custom registry is not an instance ofDefaultSubscriptionRegistry
, the provided PathMatcher is not used and must be configured directly on the custom registry.
getSubscriptionRegistry
public SubscriptionRegistry getSubscriptionRegistry()
setSelectorHeaderName
public 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 boolean expression to be applied to the headers of messages matched to the subscription.For example:
headers.foo == 'bar'
By default this is set to "selector". You can set it to a different name, or to
null
to turn off support for a selector header.- 参数:
selectorHeaderName
- the name to use for a selector header- 从以下版本开始:
- 4.3.17
- 另请参阅:
setSubscriptionRegistry(org.springframework.messaging.simp.broker.SubscriptionRegistry)
,DefaultSubscriptionRegistry.setSelectorHeaderName(String)
setPathMatcher
public void setPathMatcher(PathMatcher pathMatcher)
When configured, the given PathMatcher is passed down to the underlying SubscriptionRegistry to use for matching destination to subscriptions.Default is a standard
AntPathMatcher
.
setCacheLimit
public void setCacheLimit(Integer cacheLimit)
When configured, the specified cache limit is passed down to the underlying SubscriptionRegistry, overriding any default there.With a standard
DefaultSubscriptionRegistry
, the default cache limit is 1024.
setTaskScheduler
public void setTaskScheduler(TaskScheduler taskScheduler)
Configure theTaskScheduler
to use for providing heartbeat support. Setting this property also sets theheartbeatValue
to "10000, 10000".By default this is not set.
- 从以下版本开始:
- 4.2
getTaskScheduler
public TaskScheduler getTaskScheduler()
Return the configured TaskScheduler.- 从以下版本开始:
- 4.2
setHeartbeatValue
public 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.By default this is set to "0, 0" unless the
taskScheduler
in which case the default becomes "10000,10000" (in milliseconds).- 从以下版本开始:
- 4.2
getHeartbeatValue
public long[] getHeartbeatValue()
The configured value for the heart-beat settings.- 从以下版本开始:
- 4.2
setHeaderInitializer
public void setHeaderInitializer(MessageHeaderInitializer headerInitializer)
Configure aMessageHeaderInitializer
to apply to the headers of all messages sent to the client outbound channel.By default this property is not set.
- 从以下版本开始:
- 4.1
getHeaderInitializer
public MessageHeaderInitializer getHeaderInitializer()
Return the configured header initializer.- 从以下版本开始:
- 4.1
startInternal
public void startInternal()
stopInternal
public void stopInternal()
handleMessageInternal
protected void handleMessageInternal(Message<?> message)
sendMessageToSubscribers
protected void sendMessageToSubscribers(String destination, Message<?> message)