org.springframework.messaging.simp.SimpMessageSendingOperations .
Also provides methods for sending messages to a user. See
UserDestinationResolver for more on user destinations.
| Modifier and Type | Field and Description |
|---|---|
| private String | |
| private MessageHeaderInitializer | |
| private final MessageChannel | |
| private volatile long |
| Access | Constructor and Description |
|---|---|
| public | SimpMessagingTemplate(MessageChannel
the message channel (never messageChannel)null)Create a new |
| Modifier and Type | Method and Description |
|---|---|
| public void | convertAndSendToUser(String
the user that should receive the message. user, String the destination to send the message to. destination, Object the payload to send payload)Implements org. |
| public void | convertAndSendToUser(String
the user that should receive the message (must not be user, String null)the destination to send the message to (must not be destination, Object null)the payload to send (may be payload, Map<String, Object> null)the message headers (may be headers)null)Implements org. |
| public void | convertAndSendToUser(String
the user that should receive the message (must not be user, String null)the destination to send the message to (must not be destination, Object null)the payload to send (may be payload, MessagePostProcessor null)a postProcessor to post-process or modify the created message postProcessor)Implements org. |
| public void | convertAndSendToUser(String
the user that should receive the message user, String the destination to send the message to destination, Object the payload to send payload, Map<String, Object> the message headers headers, MessagePostProcessor a postProcessor to post-process or modify the created message postProcessor)Implements org. |
| protected void | doSend(String destination, Message<?> message)
Implements abstract org. |
| public MessageHeaderInitializer | |
| public MessageChannel | |
| public long | |
| public String | |
| private void | |
| protected Map | processHeadersToSend(Map<String, Object>
the headers to send (or headers)null if none)Overrides org. NATIVE_HEADERS.
|
| public void | send(Message<?>
the message to send (never message)null)Overrides org. Implements org. SimpMessageHeaderAccessor#DESTINATION_HEADER then the message is sent without
further changes.
|
| private void | |
| public void | setHeaderInitializer(MessageHeaderInitializer headerInitializer)
Configure a |
| public void | setSendTimeout(long sendTimeout)
Specify the timeout value to use for send operations (in milliseconds). |
| public void | setUserDestinationPrefix(String prefix)
Configure the prefix to use for destinations targeting a specific user. |
| destinationPrefix | back to summary |
|---|---|
| private String destinationPrefix | |
| headerInitializer | back to summary |
|---|---|
| private MessageHeaderInitializer headerInitializer
| |
| messageChannel | back to summary |
|---|---|
| private final MessageChannel messageChannel | |
| sendTimeout | back to summary |
|---|---|
| private volatile long sendTimeout | |
| SimpMessagingTemplate | back to summary |
|---|---|
| public SimpMessagingTemplate(MessageChannel messageChannel) Create a new
| |
| convertAndSendToUser | back to summary |
|---|---|
| public void convertAndSendToUser(String user, String destination, Object payload) throws MessagingException Implements org. Doc from org. Send a message to the given user. | |
| convertAndSendToUser | back to summary |
|---|---|
| public void convertAndSendToUser(String user, String destination, Object payload, Map<String, Object> headers) throws MessagingException Implements org. Doc from org. Send a message to the given user. By default headers are interpreted as native headers (e.g. STOMP) and
are saved under a special key in the resulting Spring
If the map already contains the key
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);
Note if the | |
| convertAndSendToUser | back to summary |
|---|---|
| public void convertAndSendToUser(String user, String destination, Object payload, MessagePostProcessor postProcessor) throws MessagingException Implements org. Doc from org. Send a message to the given user.
| |
| convertAndSendToUser | back to summary |
|---|---|
| public void convertAndSendToUser(String user, String destination, Object payload, Map<String, Object> headers, MessagePostProcessor postProcessor) throws MessagingException Implements org. Doc from org. Send a message to the given user. See
| |
| doSend | back to summary |
|---|---|
| protected void doSend(String destination, Message<?> message) Implements abstract org.
| |
| getHeaderInitializer | back to summary |
|---|---|
| public MessageHeaderInitializer getHeaderInitializer() Return the configured header initializer.
| |
| getMessageChannel | back to summary |
|---|---|
| public MessageChannel getMessageChannel() Return the configured message channel. | |
| getSendTimeout | back to summary |
|---|---|
| public long getSendTimeout() Return the configured send timeout (in milliseconds). | |
| getUserDestinationPrefix | back to summary |
|---|---|
| public String getUserDestinationPrefix() Return the configured user destination prefix. | |
| initHeaders | back to summary |
|---|---|
| private void initHeaders(SimpMessageHeaderAccessor simpAccessor) | |
| processHeadersToSend | back to summary |
|---|---|
| protected Map Overrides org. Creates a new map and puts the given headers under the key
Effectively treats the input header map as headers to be sent out to the destination. However if the given headers already contain the key Also if the given headers were prepared and obtained with
| |
| send | back to summary |
|---|---|
| public void send(Message<?> message) Overrides org. Implements org. If the headers of the given message already contain a
If a destination header is not already present ,the message is sent
to the configured | |
| sendInternal | back to summary |
|---|---|
| private void sendInternal(Message<?> message) | |
| setHeaderInitializer | back to summary |
|---|---|
| public void setHeaderInitializer(MessageHeaderInitializer headerInitializer) Configure a By default, this property is not set. | |
| setSendTimeout | back to summary |
|---|---|
| public void setSendTimeout(long sendTimeout) Specify the timeout value to use for send operations (in milliseconds). | |
| setUserDestinationPrefix | back to summary |
|---|---|
| public void setUserDestinationPrefix(String prefix) Configure the prefix to use for destinations targeting a specific user. The default value is "/user/". | |