类 UserRegistryMessageHandler
- java.lang.Object
- org.springframework.messaging.simp.user.UserRegistryMessageHandler
public class UserRegistryMessageHandler extends Object implements MessageHandler, ApplicationListener<BrokerAvailabilityEvent>
MessageHandlerthat handles user registry broadcasts from other application servers and periodically broadcasts the content of the local user registry.The aggregated information is maintained in a
MultiServerUserRegistry.- 从以下版本开始:
- 4.2
- 作者:
- Rossen Stoyanchev
构造器概要
构造器 构造器 说明 UserRegistryMessageHandler(MultiServerUserRegistry userRegistry, SimpMessagingTemplate brokerTemplate, String broadcastDestination, TaskScheduler scheduler)Constructor.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 StringgetBroadcastDestination()Return the configured destination for broadcasting UserRegistry information.longgetRegistryExpirationPeriod()Return the configured registry expiration period.voidhandleMessage(Message<?> message)Handle the given message.voidonApplicationEvent(BrokerAvailabilityEvent event)Handle an application event.voidsetRegistryExpirationPeriod(long milliseconds)Configure the amount of time (in milliseconds) before a remote user registry snapshot is considered expired.
构造器详细资料
UserRegistryMessageHandler
public UserRegistryMessageHandler(MultiServerUserRegistry userRegistry, SimpMessagingTemplate brokerTemplate, String broadcastDestination, TaskScheduler scheduler)
Constructor.- 参数:
userRegistry- the registry with local and remote user registry informationbrokerTemplate- template for broadcasting local registry informationbroadcastDestination- the destination to broadcast toscheduler- the task scheduler to use
方法详细资料
getBroadcastDestination
public String getBroadcastDestination()
Return the configured destination for broadcasting UserRegistry information.
setRegistryExpirationPeriod
public void setRegistryExpirationPeriod(long milliseconds)
Configure the amount of time (in milliseconds) before a remote user registry snapshot is considered expired.By default this is set to 20 seconds (value of 20000).
- 参数:
milliseconds- the expiration period in milliseconds
getRegistryExpirationPeriod
public long getRegistryExpirationPeriod()
Return the configured registry expiration period.
onApplicationEvent
public void onApplicationEvent(BrokerAvailabilityEvent event)
从接口复制的说明:ApplicationListenerHandle an application event.- 指定者:
onApplicationEvent在接口中ApplicationListener<BrokerAvailabilityEvent>- 参数:
event- the event to respond to
handleMessage
public void handleMessage(Message<?> message) throws MessagingException
从接口复制的说明:MessageHandlerHandle the given message.- 指定者:
handleMessage在接口中MessageHandler- 参数:
message- the message to be handled- 抛出:
MessagingException- if the handler failed to process the message