org.springframework.messaging.simp.user

## Class UserRegistryMessageHandler

- java.lang.Object
- - org.springframework.messaging.simp.user.UserRegistryMessageHandler

All Implemented Interfaces:
  EventListener, org.springframework.context.ApplicationListener<BrokerAvailabilityEvent>, MessageHandler

    public class UserRegistryMessageHandler
    extends Object
    implements MessageHandler, org.springframework.context.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`.

Since:
  4.2
Author:
  Rossen Stoyanchev

### Constructor Summary

Constructors
Constructor and Description
`UserRegistryMessageHandler(MultiServerUserRegistry userRegistry, SimpMessagingTemplate brokerTemplate, String broadcastDestination, org.springframework.scheduling.TaskScheduler scheduler)` Constructor.

### Method Summary

All Methods Instance Methods Concrete Methods
`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)`
`void` `setRegistryExpirationPeriod(long milliseconds)` Configure the amount of time (in milliseconds) before a remote user registry snapshot is considered expired.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### UserRegistryMessageHandler

    public UserRegistryMessageHandler(MultiServerUserRegistry userRegistry,
                                      SimpMessagingTemplate brokerTemplate,
                                      String broadcastDestination,
                                      org.springframework.scheduling.TaskScheduler scheduler)

Constructor.

Parameters:
  `userRegistry` - the registry with local and remote user registry information
  `brokerTemplate` - template for broadcasting local registry information
  `broadcastDestination` - the destination to broadcast to
  `scheduler` - the task scheduler to use

### Method Detail

#### 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).

Parameters:
  `milliseconds` - the expiration period in milliseconds

#### getRegistryExpirationPeriod

    public long getRegistryExpirationPeriod()

Return the configured registry expiration period.

#### onApplicationEvent

    public void onApplicationEvent(BrokerAvailabilityEvent event)

Specified by:
  `onApplicationEvent` in interface `org.springframework.context.ApplicationListener<BrokerAvailabilityEvent>`

#### handleMessage

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

Description copied from interface: `MessageHandler`
Handle the given message.

Specified by:
  `handleMessage` in interface `MessageHandler`
Parameters:
  `message` - the message to be handled
Throws:
  `MessagingException` - if the handler failed to process the message