public class UserRegistryMessageHandler extends java.lang.Object implements MessageHandler, ApplicationListener<BrokerAvailabilityEvent>
MessageHandler
that 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
.
Constructor and Description |
---|
UserRegistryMessageHandler(MultiServerUserRegistry userRegistry,
SimpMessagingTemplate brokerTemplate,
java.lang.String broadcastDestination,
TaskScheduler scheduler)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getBroadcastDestination()
Return the configured destination for broadcasting UserRegistry information.
|
long |
getRegistryExpirationPeriod()
Return the configured registry expiration period.
|
void |
handleMessage(Message<?> message)
Handle the given message.
|
void |
onApplicationEvent(BrokerAvailabilityEvent event)
Handle an application event.
|
void |
setRegistryExpirationPeriod(long milliseconds)
Configure the amount of time (in milliseconds) before a remote user
registry snapshot is considered expired.
|
public UserRegistryMessageHandler(MultiServerUserRegistry userRegistry, SimpMessagingTemplate brokerTemplate, java.lang.String broadcastDestination, TaskScheduler scheduler)
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 usepublic java.lang.String getBroadcastDestination()
public void setRegistryExpirationPeriod(long milliseconds)
By default this is set to 20 seconds (value of 20000).
milliseconds
- the expiration period in millisecondspublic long getRegistryExpirationPeriod()
public void onApplicationEvent(BrokerAvailabilityEvent event)
ApplicationListener
onApplicationEvent
in interface ApplicationListener<BrokerAvailabilityEvent>
event
- the event to respond topublic void handleMessage(Message<?> message) throws MessagingException
MessageHandler
handleMessage
in interface MessageHandler
message
- the message to be handledMessagingException