Top Description Inners Fields Constructors Methods
org.springframework.messaging.simp.user

public Class UserRegistryMessageHandler

extends Object
implements MessageHandler, ApplicationListener<BrokerAvailabilityEvent>
Class Inheritance
All Implemented Interfaces
org.springframework.context.ApplicationListener, java.util.EventListener, org.springframework.messaging.MessageHandler
Imports
java.time.Duration, java.util.concurrent.ScheduledFuture, .TimeUnit, org.springframework.context.ApplicationListener, org.springframework.lang.Nullable, org.springframework.messaging.Message, .MessageHandler, .MessagingException, org.springframework.messaging.converter.MessageConverter, org.springframework.messaging.simp.SimpMessageHeaderAccessor, .SimpMessageType, .SimpMessagingTemplate, org.springframework.messaging.simp.broker.BrokerAvailabilityEvent, org.springframework.scheduling.TaskScheduler, org.springframework.util.Assert

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.

Author
Rossen Stoyanchev
Since
4.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final String
private final SimpMessagingTemplate
private long
private volatile ScheduledFuture<?>
private final TaskScheduler
private final UserRegistryMessageHandler.UserRegistryTask
private final MultiServerUserRegistry

Constructor Summary

AccessConstructor and Description
public
UserRegistryMessageHandler(MultiServerUserRegistry
the registry with local and remote user registry information
userRegistry
,
SimpMessagingTemplate
template for broadcasting local registry information
brokerTemplate
,
String
the destination to broadcast to
broadcastDestination
,
TaskScheduler
the task scheduler to use
scheduler
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public String
getBroadcastDestination()

Return the configured destination for broadcasting UserRegistry information.

public long
getRegistryExpirationPeriod()

Return the configured registry expiration period.

public void
handleMessage(Message<?>
the message to be handled
message
)

Implements org.springframework.messaging.MessageHandler.handleMessage.

Handle the given message.

public void
onApplicationEvent(BrokerAvailabilityEvent
the event to respond to
event
)

Implements org.springframework.context.ApplicationListener.onApplicationEvent.

Handle an application event.

public void
setRegistryExpirationPeriod(long
the expiration period in milliseconds
milliseconds
)

Configure the amount of time (in milliseconds) before a remote user registry snapshot is considered expired.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

broadcastDestinationback to summary
private final String broadcastDestination
brokerTemplateback to summary
private final SimpMessagingTemplate brokerTemplate
registryExpirationPeriodback to summary
private long registryExpirationPeriod
scheduledFutureback to summary
private volatile ScheduledFuture<?> scheduledFuture
Annotations
@Nullable
schedulerback to summary
private final TaskScheduler scheduler
schedulerTaskback to summary
private final UserRegistryMessageHandler.UserRegistryTask schedulerTask
userRegistryback to summary
private final MultiServerUserRegistry userRegistry

Constructor Detail

UserRegistryMessageHandlerback to summary
public UserRegistryMessageHandler(MultiServerUserRegistry userRegistry, SimpMessagingTemplate brokerTemplate, String broadcastDestination, TaskScheduler scheduler)

Constructor.

Parameters
userRegistry:MultiServerUserRegistry

the registry with local and remote user registry information

brokerTemplate:SimpMessagingTemplate

template for broadcasting local registry information

broadcastDestination:String

the destination to broadcast to

scheduler:TaskScheduler

the task scheduler to use

Method Detail

getBroadcastDestinationback to summary
public String getBroadcastDestination()

Return the configured destination for broadcasting UserRegistry information.

getRegistryExpirationPeriodback to summary
public long getRegistryExpirationPeriod()

Return the configured registry expiration period.

handleMessageback to summary
public void handleMessage(Message<?> message) throws MessagingException

Implements org.springframework.messaging.MessageHandler.handleMessage.

Doc from org.springframework.messaging.MessageHandler.handleMessage.

Handle the given message.

Parameters
message:Message<?>

the message to be handled

Annotations
@Override
Exceptions
MessagingException:
if the handler failed to process the message
onApplicationEventback to summary
public void onApplicationEvent(BrokerAvailabilityEvent event)

Implements org.springframework.context.ApplicationListener.onApplicationEvent.

Doc from org.springframework.context.ApplicationListener.onApplicationEvent.

Handle an application event.

Parameters
event:BrokerAvailabilityEvent

the event to respond to

Annotations
@Override
setRegistryExpirationPeriodback to summary
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).

Parameters
milliseconds:long

the expiration period in milliseconds

Annotations
@SuppressWarnings:unused
org.springframework.messaging.simp.user back to summary

private Class UserRegistryMessageHandler.UserRegistryTask

extends Object
implements Runnable
Class Inheritance
  • java.lang.Object
  • org.springframework.messaging.simp.user.UserRegistryMessageHandler.UserRegistryTask
All Implemented Interfaces
java.lang.Runnable

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

UserRegistryTaskback to summary
private UserRegistryTask()

Method Detail

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override