public class UserDestinationMessageHandler extends Object implements MessageHandler, SmartLifecycle
See UserDestinationResolver for more details and examples.
| Constructor and Description |
|---|
UserDestinationMessageHandler(SubscribableChannel clientInChannel,
SubscribableChannel brokerChannel,
UserDestinationResolver userDestinationResolver)
Create an instance of the handler with the given messaging template and a
user destination resolver.
|
| Modifier and Type | Method and Description |
|---|---|
MessageSendingOperations<String> |
getBrokerMessagingTemplate()
Return the configured messaging template for sending messages with
translated destinations.
|
MessageHeaderInitializer |
getHeaderInitializer() |
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 |
setHeaderInitializer(MessageHeaderInitializer headerInitializer)
Configure a
MessageHeaderInitializer to pass on to
HandlerMethodReturnValueHandlers
that send messages from controller return values. |
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 clientInChannel, SubscribableChannel brokerChannel, UserDestinationResolver userDestinationResolver)
clientInChannel - the channel for receiving messages from clients (e.g. WebSocket clients)brokerChannel - the channel for sending messages with translated user destinationsuserDestinationResolver - the resolver to use to find queue suffixes for a userpublic MessageSendingOperations<String> getBrokerMessagingTemplate()
public UserDestinationResolver getUserDestinationResolver()
UserDestinationResolver.public void setHeaderInitializer(MessageHeaderInitializer headerInitializer)
MessageHeaderInitializer to pass on to
HandlerMethodReturnValueHandlers
that send messages from controller return values.
By default this property 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 boolean isRunning()
LifecycleIn the case of a container, this will return true
only if all components that apply are currently running.
public final void start()
LifecycleIn 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 in cases where asynchronous stop behavior is necessary.
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)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 void handleMessage(Message<?> message) throws MessagingException
MessageHandlerhandleMessage in interface MessageHandlermessage - the message to be handledMessagingException