MessageSendingOperations with methods for use with
the Spring Framework support for Simple Messaging Protocols (like STOMP).
For more on user destinations see
UserDestinationResolver.
Generally it is expected the user is the one authenticated with the
WebSocket session (or by extension the user authenticated with the
handshake request that started the session). However if the session is
not authenticated, it is also possible to pass the session id (if known)
in place of the user name. Keep in mind though that in that scenario,
you must use one of the overloaded methods that accept headers making sure the
sessionId header has been set accordingly.
| 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)Send a message to the given user. |
| 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)Send a message to the given user. |
| 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)Send a message to the given user. |
| 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)Send a message to the given user. |
| convertAndSendToUser | back to summary |
|---|---|
| public void convertAndSendToUser(String user, String destination, Object payload) throws MessagingException 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 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 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 Send a message to the given user. See | |