public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
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 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:
logger
Constructor and Description |
---|
StompBrokerRelayMessageHandler(SubscribableChannel clientInChannel,
MessageChannel clientOutChannel,
SubscribableChannel brokerChannel,
Collection<String> destinationPrefixes)
Create a StompBrokerRelayMessageHandler instance with the given message channels
and destination prefixes.
|
Modifier and Type | Method and Description |
---|---|
String |
getClientLogin() |
String |
getClientPasscode() |
String |
getRelayHost() |
int |
getRelayPort() |
long |
getSystemHeartbeatReceiveInterval() |
long |
getSystemHeartbeatSendInterval() |
String |
getSystemLogin() |
String |
getSystemPasscode() |
TcpOperations<byte[]> |
getTcpClient()
Get the configured TCP client.
|
String |
getVirtualHost() |
protected void |
handleMessageInternal(Message<?> message) |
void |
setClientLogin(String clientLogin)
Set the login to use when creating connections to the STOMP broker on
behalf of connected clients.
|
void |
setClientPasscode(String clientPasscode)
Set the clientPasscode to use to create connections to the STOMP broker on
behalf of connected clients.
|
void |
setRelayHost(String relayHost)
Set the STOMP message broker host.
|
void |
setRelayPort(int relayPort)
Set the STOMP message broker port.
|
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.
|
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.
|
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.
|
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.
|
void |
setTcpClient(TcpOperations<byte[]> tcpClient)
Configure a TCP client for managing TCP connections to the STOMP broker.
|
void |
setVirtualHost(String virtualHost)
Set the value of the "host" header to use in STOMP CONNECT frames.
|
protected void |
startInternal() |
protected void |
stopInternal() |
checkDestinationPrefix, getApplicationEventPublisher, getDestinationPrefixes, getPhase, handleMessage, isAutoStartup, isRunning, publishBrokerAvailableEvent, publishBrokerUnavailableEvent, setApplicationEventPublisher, setAutoStartup, start, stop, stop
public StompBrokerRelayMessageHandler(SubscribableChannel clientInChannel, MessageChannel clientOutChannel, SubscribableChannel brokerChannel, Collection<String> destinationPrefixes)
clientInChannel
- the channel for receiving messages from clients (e.g. WebSocket clients)clientOutChannel
- the channel for sending messages to clients (e.g. WebSocket clients)brokerChannel
- the channel for the application to send messages to the brokerdestinationPrefixes
- the broker supported destination prefixes; destinations
that do not match the given prefix are ignored.public void setRelayHost(String relayHost)
public String getRelayHost()
public void setRelayPort(int relayPort)
public int getRelayPort()
public void setSystemHeartbeatSendInterval(long systemHeartbeatSendInterval)
The default value is 10000.
See class-level documentation for more information on the "system" connection.
public long getSystemHeartbeatSendInterval()
public void setSystemHeartbeatReceiveInterval(long heartbeatReceiveInterval)
The default value is 10000.
See class-level documentation for more information on the "system" connection.
public long getSystemHeartbeatReceiveInterval()
public void setClientLogin(String clientLogin)
By default this is set to "guest".
setSystemLogin(String)
public String getClientLogin()
getSystemLogin()
public void setClientPasscode(String clientPasscode)
By default this is set to "guest".
setSystemPasscode(String)
public String getClientPasscode()
getSystemPasscode()
public void setSystemLogin(String systemLogin)
By default this is set to "guest".
public String getSystemLogin()
public void setSystemPasscode(String systemPasscode)
By default this is set to "guest".
public String getSystemPasscode()
public void setVirtualHost(String virtualHost)
By default this property is not set.
public String getVirtualHost()
public void setTcpClient(TcpOperations<byte[]> tcpClient)
StompReactorNettyTcpClient
is used.public TcpOperations<byte[]> getTcpClient()
null
unless not configured
invoked and this method is invoked before the handler is started and
hence a default implementation initialized.protected void startInternal()
startInternal
in class AbstractBrokerMessageHandler
protected void stopInternal()
stopInternal
in class AbstractBrokerMessageHandler
protected void handleMessageInternal(Message<?> message)
handleMessageInternal
in class AbstractBrokerMessageHandler