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 recognized because they 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 the the
login
passcode
,
heartbeat send
and
receive
intervals.
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 |
getRelayHost() |
int |
getRelayPort() |
long |
getSystemHeartbeatReceiveInterval() |
long |
getSystemHeartbeatSendInterval() |
String |
getSystemLogin() |
String |
getSystemPasscode() |
String |
getVirtualHost() |
protected void |
handleMessageInternal(Message<?> message) |
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 "system" connection used to send messages to the STOMP
broker without having a client session (e.g.
|
void |
setSystemPasscode(String systemPasscode)
Set the passcode for the "system" connection used to send messages to the STOMP
broker without having a client session (e.g.
|
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 setSystemLogin(String systemLogin)
See class-level documentation for more information on the "system" connection.
public String getSystemLogin()
public void setSystemPasscode(String systemPasscode)
See class-level documentation for more information on the "system" connection.
public String getSystemPasscode()
public void setVirtualHost(String virtualHost)
By default this property is not set.
public String getVirtualHost()
protected void startInternal()
startInternal
in class AbstractBrokerMessageHandler
protected void stopInternal()
stopInternal
in class AbstractBrokerMessageHandler
protected void handleMessageInternal(Message<?> message)
handleMessageInternal
in class AbstractBrokerMessageHandler