public class UserDestinationMessageHandler extends Object implements MessageHandler, org.springframework.context.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.
|
UserDestinationResolver |
getUserDestinationResolver()
Return the configured
UserDestinationResolver. |
void |
handleMessage(Message<?> message)
Handle the given message.
|
boolean |
isRunning() |
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() |
void |
stop() |
void |
stop(Runnable callback) |
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(@Nullable
String destination)
By default this is not set.
destination - the target destination.@Nullable public String getBroadcastDestination()
public MessageSendingOperations<String> getBrokerMessagingTemplate()
public void setHeaderInitializer(@Nullable
MessageHeaderInitializer headerInitializer)
MessageHeaderInitializer to initialize the
headers of resolved target messages.
By default this is not set.
@Nullable public MessageHeaderInitializer getHeaderInitializer()
public final void start()
start in interface org.springframework.context.Lifecyclepublic final void stop()
stop in interface org.springframework.context.Lifecyclepublic final void stop(Runnable callback)
stop in interface org.springframework.context.SmartLifecyclepublic final boolean isRunning()
isRunning in interface org.springframework.context.Lifecyclepublic void handleMessage(Message<?> message) throws MessagingException
MessageHandlerhandleMessage in interface MessageHandlermessage - the message to be handledMessagingException - if the handler failed to process the message