org.springframework.messaging.MessageHandler that handles messages by
forwarding them to a STOMP broker.
For each new CONNECT message, an independent TCP
connection to the broker is opened and used exclusively for all messages from the
client that originated the CONNECT message. Messages from the same client are
identified through the session id message header. Reversely, when the STOMP broker
sends messages back on the TCP connection, those messages are enriched with the
session id of the client and sent back downstream through the MessageChannel
provided to the constructor.
This class also automatically opens a default "system" TCP connection to the message broker that is used for sending messages that originate from the server application (as opposed to from a client). Such messages are not associated with any client and therefore do not have a session id header. The "system" connection is effectively shared and cannot be used to receive messages. Several properties are provided to configure the "system" connection including:
| Modifier and Type | Class and Description |
|---|---|
| private class | |
| private class | |
| private class | |
| public static interface | StompBrokerRelayMessageHandler.
Contract for access to session counters. |
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private String | |
| private String | |
| private final Map | |
| private static final byte[] | |
| private static final CompletableFuture | |
| private MessageHeaderInitializer | |
| private static final StompHeaderAccessor | |
| private static final Message | |
| private static final long | HEARTBEAT_MULTIPLIER
STOMP recommended error of margin for receiving heartbeats. |
| private static final int | MAX_TIME_TO_CONNECTED_FRAME
Heartbeat starts once CONNECTED frame with heartbeat settings is received. |
| private static final boolean | |
| private static final boolean | |
| private String | |
| private int | |
| private final StompBrokerRelayMessageHandler. | |
| public static final String | SYSTEM_SESSION_ID
The system session ID. |
| private long | |
| private long | |
| private String | |
| private String | |
| private final Map | |
| private TaskScheduler | |
| private TcpOperations | |
| private String |
| Access | Constructor and Description |
|---|---|
| public | StompBrokerRelayMessageHandler(SubscribableChannel
the channel for receiving messages from clients (e.g. WebSocket clients) inboundChannel, MessageChannel the channel for sending messages to clients (e.g. WebSocket clients) outboundChannel, SubscribableChannel the channel for the application to send messages to the broker brokerChannel, Collection<String> the broker supported destination prefixes; destinations
that do not match the given prefix are ignored. destinationPrefixes)Create a StompBrokerRelayMessageHandler instance with the given message channels and destination prefixes. |
| Modifier and Type | Method and Description |
|---|---|
| public String | getClientLogin()
Return the configured login to use for connections to the STOMP broker on behalf of connected clients. |
| public String | getClientPasscode()
Return the configured passcode to use for connections to the STOMP broker on behalf of connected clients. |
| public int | |
| public MessageHeaderInitializer | |
| public String | |
| public int | |
| public StompBrokerRelayMessageHandler. | |
| public String | |
| public long | getSystemHeartbeatReceiveInterval()
Return the interval, in milliseconds, at which the "system" connection expects to receive heartbeats from the STOMP broker. |
| public long | getSystemHeartbeatSendInterval()
Return the interval, in milliseconds, at which the "system" connection will send heartbeats to the STOMP broker. |
| public String | |
| public String | |
| public Map | |
| public TaskScheduler | |
| public TcpOperations | getTcpClient()
Get the configured TCP client (never |
| private String | |
| public String | |
| protected void | handleMessageInternal(Message<?> message)
Implements abstract org.
|
| private TcpOperations | |
| public void | setClientLogin(String clientLogin)
Set the login to use when creating connections to the STOMP broker on behalf of connected clients. |
| public void | setClientPasscode(String clientPasscode)
Set the client passcode to use to create connections to the STOMP broker on behalf of connected clients. |
| public void | setHeaderInitializer(MessageHeaderInitializer headerInitializer)
Configure a |
| public void | |
| public void | |
| public void | setSystemHeartbeatReceiveInterval(long heartbeatReceiveInterval)
Set the maximum interval, in milliseconds, at which the "system" connection expects, in the absence of any other data, to receive a heartbeat from the STOMP broker. |
| public void | setSystemHeartbeatSendInterval(long systemHeartbeatSendInterval)
Set the interval, in milliseconds, at which the "system" connection will, in the absence of any other data being sent, send a heartbeat to the STOMP broker. |
| public void | setSystemLogin(String systemLogin)
Set the login for the shared "system" connection used to send messages to the STOMP broker from within the application, i.e. messages not associated with a specific client session (e.g. REST/HTTP request handling method). |
| public void | setSystemPasscode(String systemPasscode)
Set the passcode for the shared "system" connection used to send messages to the STOMP broker from within the application, i.e. messages not associated with a specific client session (e.g. REST/HTTP request handling method). |
| public void | setSystemSubscriptions(Map<String, MessageHandler>
the destinations to subscribe to. subscriptions)Configure one more destinations to subscribe to on the shared "system" connection along with MessageHandler's to handle received messages. |
| public void | setTaskScheduler(TaskScheduler
the scheduler to use taskScheduler)Configure the |
| public void | setTcpClient(TcpOperations<byte[]> tcpClient)
Configure a TCP client for managing TCP connections to the STOMP broker. |
| public void | setVirtualHost(String virtualHost)
Set the value of the "host" header to use in STOMP CONNECT frames. |
| protected void | |
| protected void | |
| public String |