public class UserDestinationMessageHandler extends Object implements MessageHandler, SmartLifecycle
MessageHandler with support for "user" destinations.
 Listens for messages with "user" destinations, translates their destination to actual target destinations unique to the active session(s) of a user, and then sends the resolved messages to the broker channel to be delivered.
| Constructor and Description | 
|---|
UserDestinationMessageHandler(SubscribableChannel clientInboundChannel,
                             SubscribableChannel brokerChannel,
                             UserDestinationResolver resolver)
Create an instance with the given client and broker channels subscribing
 to handle messages from each and then sending any resolved messages to the
 broker channel. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
String | 
getBroadcastDestination()
Return the configured destination for unresolved messages. 
 | 
MessageSendingOperations<String> | 
getBrokerMessagingTemplate()
Return the messaging template used to send resolved messages to the
 broker channel. 
 | 
MessageHeaderInitializer | 
getHeaderInitializer()
Return the configured header initializer. 
 | 
int | 
getPhase()
Return the phase value of this object. 
 | 
UserDestinationResolver | 
getUserDestinationResolver()
Return the configured  
UserDestinationResolver. | 
void | 
handleMessage(Message<?> message)
Handle the given message. 
 | 
boolean | 
isAutoStartup()
Returns  
true if this Lifecycle component should get
 started automatically by the container at the time that the containing
 ApplicationContext gets refreshed. | 
boolean | 
isRunning()
Check whether this component is currently running. 
 | 
void | 
setBroadcastDestination(String destination)
Set a destination to broadcast messages to that remain unresolved because
 the user is not connected. 
 | 
void | 
setHeaderInitializer(MessageHeaderInitializer headerInitializer)
Configure a custom  
MessageHeaderInitializer to initialize the
 headers of resolved target messages. | 
void | 
start()
Start this component. 
 | 
void | 
stop()
Stop this component, typically in a synchronous fashion, such that the component is
 fully stopped upon return of this method. 
 | 
void | 
stop(Runnable callback)
Indicates that a Lifecycle component must stop if it is currently running. 
 | 
String | 
toString()  | 
public UserDestinationMessageHandler(SubscribableChannel clientInboundChannel, SubscribableChannel brokerChannel, UserDestinationResolver resolver)
clientInboundChannel - messages received from clients.brokerChannel - messages sent to the broker.resolver - the resolver for "user" destinations.public UserDestinationResolver getUserDestinationResolver()
UserDestinationResolver.public void setBroadcastDestination(String destination)
By default this is not set.
destination - the target destination.public String getBroadcastDestination()
public MessageSendingOperations<String> getBrokerMessagingTemplate()
public void setHeaderInitializer(MessageHeaderInitializer headerInitializer)
MessageHeaderInitializer to initialize the
 headers of resolved target messages.
 By default this is not set.
public MessageHeaderInitializer getHeaderInitializer()
public int getPhase()
Phasedpublic boolean isAutoStartup()
SmartLifecycletrue if this Lifecycle component should get
 started automatically by the container at the time that the containing
 ApplicationContext gets refreshed.
 A value of false indicates that the component is intended to
 be started through an explicit Lifecycle.start() call instead, analogous
 to a plain Lifecycle implementation.
isAutoStartup in interface SmartLifecycleLifecycle.start(), 
Phased.getPhase(), 
LifecycleProcessor.onRefresh(), 
ConfigurableApplicationContext.refresh()public final void start()
LifecycleShould not throw an exception if the component is already running.
In the case of a container, this will propagate the start signal to all components that apply.
start in interface LifecycleSmartLifecycle.isAutoStartup()public final void stop()
LifecycleSmartLifecycle
 and its stop(Runnable) variant when asynchronous stop behavior is necessary.
 Note that this stop notification is not guaranteed to come before destruction: On
 regular shutdown, Lifecycle beans will first receive a stop notification before
 the general destruction callbacks are being propagated; however, on hot refresh during a
 context's lifetime or on aborted refresh attempts, only destroy methods will be called.
 
Should not throw an exception if the component isn't started yet.
In the case of a container, this will propagate the stop signal to all components that apply.
stop in interface LifecycleSmartLifecycle.stop(Runnable), 
DisposableBean.destroy()public final void stop(Runnable callback)
SmartLifecycleThe provided callback is used by the LifecycleProcessor to support
 an ordered, and potentially concurrent, shutdown of all components having a
 common shutdown order value. The callback must be executed after
 the SmartLifecycle component does indeed stop.
 
The LifecycleProcessor will call only this variant of the
 stop method; i.e. Lifecycle.stop() will not be called for
 SmartLifecycle implementations unless explicitly delegated to within
 the implementation of this method.
stop in interface SmartLifecycleLifecycle.stop(), 
Phased.getPhase()public final boolean isRunning()
LifecycleIn the case of a container, this will return true only if all
 components that apply are currently running.
public void handleMessage(Message<?> message) throws MessagingException
MessageHandlerhandleMessage in interface MessageHandlermessage - the message to be handledMessagingException