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
HandlerMethodReturnValueHandler s
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
HandlerMethodReturnValueHandler
s
that send messages from controller return values.
By default this property is not set.
public MessageHeaderInitializer getHeaderInitializer()
public int getPhase()
Phased
public boolean isAutoStartup()
SmartLifecycle
true
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 SmartLifecycle
Lifecycle.start()
,
Phased.getPhase()
,
LifecycleProcessor.onRefresh()
,
ConfigurableApplicationContext.refresh()
public final boolean isRunning()
Lifecycle
In the case of a container, this will return true
only if all components that apply are currently running.
public final void start()
Lifecycle
In the case of a container, this will propagate the start signal to all components that apply.
start
in interface Lifecycle
SmartLifecycle.isAutoStartup()
public final void stop()
Lifecycle
SmartLifecycle
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 Lifecycle
SmartLifecycle.stop(Runnable)
public final void stop(Runnable callback)
SmartLifecycle
The 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 SmartLifecycle
Lifecycle.stop()
,
Phased.getPhase()
public void handleMessage(Message<?> message) throws MessagingException
MessageHandler
handleMessage
in interface MessageHandler
message
- the message to be handledMessagingException