Create a new {@link SimpMessagingTemplate} instance. @param messageChannel the message channel (never {@code null})
Return the configured header initializer.
Return the configured message channel.
Return the configured send timeout (in milliseconds).
Return the configured user destination prefix.
Creates a new map and puts the given headers under the key {@link NativeMessageHeaderAccessor#NATIVE_HEADERS NATIVE_HEADERS NATIVE_HEADERS NATIVE_HEADERS}. effectively treats the input header map as headers to be sent out to the destination. <p>However if the given headers already contain the key {@code NATIVE_HEADERS NATIVE_HEADERS} then the same headers instance is returned without changes. <p>Also if the given headers were prepared and obtained with {@link SimpMessageHeaderAccessor#getMessageHeaders()} then the same headers instance is also returned without changes.
If the headers of the given message already contain a {@link hunt.stomp.simp.SimpMessageHeaderAccessor#DESTINATION_HEADER SimpMessageHeaderAccessor#DESTINATION_HEADER} then the message is sent without further changes. <p>If a destination header is not already present ,the message is sent to the configured {@link #setDefaultDestination(Object) defaultDestination} or an exception an {@code IllegalStateException} is raised if that isn't configured. @param message the message to send (never {@code null})
Configure a {@link MessageHeaderInitializer} to apply to the headers of all messages created through the {@code SimpMessagingTemplate}. <p>By default, this property is not set.
Specify the timeout value to use for send operations (in milliseconds).
Configure the prefix to use for destinations targeting a specific user. <p>The default value is "/user/". @see hunt.stomp.simp.user.UserDestinationMessageHandler
Send a message to the given user. @param user the user that should receive the message. @param destination the destination to send the message to. @param payload the payload to send
Send a message to the given user. <p>By default headers are interpreted as native headers (e.g. STOMP) and are saved under a special key in the resulting Spring {@link hunt.stomp.Message Message}. In effect when the message leaves the application, the provided headers are included with it and delivered to the destination (e.g. the STOMP client or broker). <p>If the map already contains the key {@link hunt.stomp.support.NativeMessageHeaderAccessor#NATIVE_HEADERS "nativeHeaders"} or was prepared with {@link hunt.stomp.simp.SimpMessageHeaderAccessor SimpMessageHeaderAccessor} then the headers are used directly. A common expected case is providing a content type (to influence the message conversion) and native headers. This may be done as follows: <pre class="code"> SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.create(); accessor.setContentType(MimeTypeUtils.TEXT_PLAIN); accessor.setNativeHeader("foo", "bar"); accessor.setLeaveMutable(true); MessageHeaders headers = accessor.getMessageHeaders(); messagingTemplate.convertAndSendToUser(user, destination, payload, headers); </pre> <p><strong>Note:</strong> if the {@code MessageHeaders} are mutable as in the above example, implementations of this interface should take notice and update the headers in the same instance (rather than copy or re-create it) and then set it immutable before sending the final message. @param user the user that should receive the message (must not be {@code null}) @param destination the destination to send the message to (must not be {@code null}) @param payload the payload to send (may be {@code null}) @param headers the message headers (may be {@code null})
Send a message to the given user. @param user the user that should receive the message (must not be {@code null}) @param destination the destination to send the message to (must not be {@code null}) @param payload the payload to send (may be {@code null}) @param postProcessor a postProcessor to post-process or modify the created message
Send a message to the given user. <p>See {@link #convertAndSend(Object, Object, java.util.Map)} for important notes regarding the input headers. @param user the user that should receive the message @param destination the destination to send the message to @param payload the payload to send @param headers the message headers @param postProcessor a postProcessor to post-process or modify the created message
An implementation of {@link hunt.stomp.simp.SimpMessageSendingOperations}.
<p>Also provides methods for sending messages to a user. See {@link hunt.stomp.simp.user.UserDestinationResolver UserDestinationResolver} for more on user destinations.
@author Rossen Stoyanchev @since 4.0