MessageHandler with support for "user" destinations.
Listen for messages with "user" destinations, translate the destination to a target destination that's unique to the active user session(s), and send to the broker channel for delivery.
| Modifier and Type | Class and Description |
|---|---|
| private static class | UserDestinationMessageHandler.BroadcastHandler
A handler that broadcasts locally unresolved messages to the broker and also handles similar broadcasts received from the broker. |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private UserDestinationMessageHandler. | |
| private final SubscribableChannel | |
| private final SubscribableChannel | |
| private final UserDestinationResolver | |
| private MessageHeaderInitializer | |
| private final Object | |
| private static final Log | |
| private Integer | |
| private volatile boolean | |
| private final UserDestinationMessageHandler. |
| Access | Constructor and Description |
|---|---|
| public | UserDestinationMessageHandler(SubscribableChannel
messages received from clients. clientInboundChannel, SubscribableChannel messages sent to the broker. brokerChannel, UserDestinationResolver the resolver for "user" destinations. destinationResolver)Create an instance with the given client and broker channels to subscribe to, and then send resolved messages to the broker channel. |
| Modifier and Type | Method and Description |
|---|---|
| public String | |
| public MessageSendingOperations | getBrokerMessagingTemplate()
Return the messaging template used to send resolved messages to the broker channel. |
| public MessageHeaderInitializer | |
| public int | getPhase()
Overrides default org. The default implementation returns |
| public UserDestinationResolver | |
| public void | handleMessage(Message<?>
the message to be handled sourceMessage)Implements org. |
| private void | |
| public final boolean | isRunning()
Implements org. |
| public void | setBroadcastDestination(String
the target destination. destination)Set a destination to broadcast messages to that remain unresolved because the user is not connected. |
| public void | setHeaderInitializer(MessageHeaderInitializer headerInitializer)
Configure a custom |
| public void | setPhase(int phase)
Set the phase that this handler should run in. By default, this is |
| public final void | |
| public final void | stop()
Implements org. |
| public final void | stop(Runnable callback)
Overrides default org. |
| public String |
| broadcastHandler | back to summary |
|---|---|
| private UserDestinationMessageHandler. | |
| brokerChannel | back to summary |
|---|---|
| private final SubscribableChannel brokerChannel | |
| clientInboundChannel | back to summary |
|---|---|
| private final SubscribableChannel clientInboundChannel | |
| destinationResolver | back to summary |
|---|---|
| private final UserDestinationResolver destinationResolver | |
| headerInitializer | back to summary |
|---|---|
| private MessageHeaderInitializer headerInitializer
| |
| lifecycleMonitor | back to summary |
|---|---|
| private final Object lifecycleMonitor | |
| logger | back to summary |
|---|---|
| private static final Log logger | |
| phase | back to summary |
|---|---|
| private Integer phase
| |
| running | back to summary |
|---|---|
| private volatile boolean running | |
| sendHelper | back to summary |
|---|---|
| private final UserDestinationMessageHandler. | |
| UserDestinationMessageHandler | back to summary |
|---|---|
| public UserDestinationMessageHandler(SubscribableChannel clientInboundChannel, SubscribableChannel brokerChannel, UserDestinationResolver destinationResolver) Create an instance with the given client and broker channels to subscribe to, and then send resolved messages to the broker channel.
| |
| getBroadcastDestination | back to summary |
|---|---|
| public String getBroadcastDestination() Return the configured destination for unresolved messages.
| |
| getBrokerMessagingTemplate | back to summary |
|---|---|
| public MessageSendingOperations Return the messaging template used to send resolved messages to the broker channel. | |
| getHeaderInitializer | back to summary |
|---|---|
| public MessageHeaderInitializer getHeaderInitializer() Return the configured header initializer.
| |
| getPhase | back to summary |
|---|---|
| public int getPhase() Overrides default org. Doc from org. Return the phase that this lifecycle object is supposed to run in. The default implementation returns
| |
| getUserDestinationResolver | back to summary |
|---|---|
| public UserDestinationResolver getUserDestinationResolver() Return the configured | |
| handleMessage | back to summary |
|---|---|
| public void handleMessage(Message<?> sourceMessage) throws MessagingException Implements org. Doc from org. Handle the given message.
| |
| initHeaders | back to summary |
|---|---|
| private void initHeaders(SimpMessageHeaderAccessor headerAccessor) | |
| isRunning | back to summary |
|---|---|
| public final boolean isRunning() Implements org. Doc from org. Check whether this component is currently running. In the case of a container, this will return
| |
| setBroadcastDestination | back to summary |
|---|---|
| public void setBroadcastDestination(String destination) Set a destination to broadcast messages to that remain unresolved because the user is not connected. In a multi-application server scenario this gives other application servers a chance to try. By default this is not set.
| |
| setHeaderInitializer | back to summary |
|---|---|
| public void setHeaderInitializer(MessageHeaderInitializer headerInitializer) Configure a custom By default this is not set. | |
| setPhase | back to summary |
|---|---|
| public void setPhase(int phase) Set the phase that this handler should run in. By default, this is
| |
| start | back to summary |
|---|---|
| public final void start() Implements org. Doc from org. Start this component. Should 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.
| |
| stop | back to summary |
|---|---|
| public final void stop() Implements org. Doc from org. Stop this component, typically in a synchronous fashion, such that the component is
fully stopped upon return of this method. Consider implementing Note that this stop notification is not guaranteed to come before destruction:
On regular shutdown, Should not throw an exception if the component is not running (not started yet). In the case of a container, this will propagate the stop signal to all components that apply.
| |
| stop | back to summary |
|---|---|
| public final void stop(Runnable callback) Overrides default org. Doc from org. Indicates that a Lifecycle component must stop if it is currently running. The provided callback is used by the The The default implementation delegates to
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |
| Modifier and Type | Field and Description |
|---|---|
| private final String | |
| private final MessageSendingOperations | |
| private static final List |
| Access | Constructor and Description |
|---|---|
| public |
| broadcastDestination | back to summary |
|---|---|
| private final String broadcastDestination | |
| messagingTemplate | back to summary |
|---|---|
| private final MessageSendingOperations<String> messagingTemplate | |
| NO_COPY_LIST | back to summary |
|---|---|
| private static final List<String> NO_COPY_LIST | |
| BroadcastHandler | back to summary |
|---|---|
| public BroadcastHandler(MessageSendingOperations<String> template, String destination) | |
| getBroadcastDestination | back to summary |
|---|---|
| public String getBroadcastDestination() | |
| handleUnresolved | back to summary |
|---|---|
| public void handleUnresolved(Message<?> message) | |
| preHandle | back to summary |
|---|---|
public Message
| |
| Modifier and Type | Field and Description |
|---|---|
| private final MessageChannel | |
| private final MessageSendingOperations | |
| private final Map |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public MessageSendingOperations | |
| private MessageSendingOperations | |
| public void |
| brokerChannel | back to summary |
|---|---|
| private final MessageChannel brokerChannel | |
| messagingTemplate | back to summary |
|---|---|
| private final MessageSendingOperations<String> messagingTemplate | |
| orderedMessagingTemplates | back to summary |
|---|---|
| private final Map<String, MessageSendingOperations<String>> orderedMessagingTemplates
| |
| SendHelper | back to summary |
|---|---|
| pack-priv SendHelper(MessageChannel clientInboundChannel, MessageChannel brokerChannel) | |
| checkDisconnect | back to summary |
|---|---|
| public void checkDisconnect(Message<?> message) | |
| getMessagingTemplate | back to summary |
|---|---|
| public MessageSendingOperations | |
| getTemplateToUse | back to summary |
|---|---|
| private MessageSendingOperations | |
| send | back to summary |
|---|---|
| public void send(UserDestinationResult destinationResult, Message<?> message) throws MessagingException | |