private class StompBrokerRelayMessageHandler.SystemStompConnectionHandler extends StompBrokerRelayMessageHandler.StompConnectionHandler
Constructor and Description |
---|
SystemStompConnectionHandler(StompHeaderAccessor connectHeaders) |
Modifier and Type | Method and Description |
---|---|
void |
afterConnectionClosed()
Invoked after the connection is closed.
|
protected void |
afterStompConnected(StompHeaderAccessor connectedHeaders)
Invoked after the STOMP CONNECTED frame is received.
|
ListenableFuture<java.lang.Void> |
forward(Message<?> message,
StompHeaderAccessor accessor)
Forward the given message to the STOMP broker.
|
protected void |
handleInboundMessage(Message<?> message) |
protected void |
handleTcpConnectionFailure(java.lang.String errorMessage,
java.lang.Throwable ex)
Invoked when any TCP connectivity issue is detected, i.e.
|
private void |
sendSystemSubscriptions() |
afterConnected, afterConnectFailure, clearConnection, getSessionId, getTcpConnection, handleFailure, handleMessage, toString
public SystemStompConnectionHandler(StompHeaderAccessor connectHeaders)
protected void afterStompConnected(StompHeaderAccessor connectedHeaders)
StompBrokerRelayMessageHandler.StompConnectionHandler
afterStompConnected
in class StompBrokerRelayMessageHandler.StompConnectionHandler
private void sendSystemSubscriptions()
protected void handleInboundMessage(Message<?> message)
handleInboundMessage
in class StompBrokerRelayMessageHandler.StompConnectionHandler
protected void handleTcpConnectionFailure(java.lang.String errorMessage, java.lang.Throwable ex)
StompBrokerRelayMessageHandler.StompConnectionHandler
handleTcpConnectionFailure
in class StompBrokerRelayMessageHandler.StompConnectionHandler
public void afterConnectionClosed()
TcpConnectionHandler
afterConnectionClosed
in interface TcpConnectionHandler<byte[]>
afterConnectionClosed
in class StompBrokerRelayMessageHandler.StompConnectionHandler
public ListenableFuture<java.lang.Void> forward(Message<?> message, StompHeaderAccessor accessor)
StompBrokerRelayMessageHandler.StompConnectionHandler
The method checks whether we have an active TCP connection and have received the STOMP CONNECTED frame. For client messages this should be false only if we lose the TCP connection around the same time when a client message is being forwarded, so we simply log the ignored message at debug level. For messages from within the application being sent on the "system" connection an exception is raised so that components sending the message have a chance to handle it -- by default the broker message channel is synchronous.
Note that if messages arrive concurrently around the same time a TCP connection is lost, there is a brief period of time before the connection is reset when one or more messages may sneak through and an attempt made to forward them. Rather than synchronizing to guard against that, this method simply lets them try and fail. For client sessions that may result in an additional STOMP ERROR frame(s) being sent downstream but code handling that downstream should be idempotent in such cases.
forward
in class StompBrokerRelayMessageHandler.StompConnectionHandler
message
- the message to send (never null
)