public class StompBrokerRelayMessageHandler extends java.lang.Object implements MessageHandler, SmartLifecycle
Modifier and Type | Class and Description |
---|---|
private class |
StompBrokerRelayMessageHandler.RelaySession |
Modifier and Type | Field and Description |
---|---|
private java.lang.String[] |
destinationPrefixes |
private Environment |
environment |
private java.lang.Object |
lifecycleMonitor |
private static Log |
logger |
private MessageChannel |
messageChannel |
private java.lang.String |
relayHost |
private int |
relayPort |
private java.util.Map<java.lang.String,StompBrokerRelayMessageHandler.RelaySession> |
relaySessions |
private boolean |
running |
private static java.lang.String |
STOMP_RELAY_SYSTEM_SESSION_ID |
private StompMessageConverter |
stompMessageConverter |
private java.lang.String |
systemLogin |
private java.lang.String |
systemPasscode |
private |
tcpClient |
Constructor and Description |
---|
StompBrokerRelayMessageHandler(MessageChannel messageChannel,
java.util.Collection<java.lang.String> destinationPrefixes) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
checkDestinationPrefix(StompCommand command,
java.lang.String destination) |
java.lang.String[] |
getDestinationPrefixes() |
int |
getPhase()
Return the phase value of this object.
|
java.lang.String |
getRelayHost() |
int |
getRelayPort() |
java.lang.String |
getSystemLogin() |
java.lang.String |
getSystemPasscode() |
void |
handleMessage(Message<?> message)
Handles the message if possible.
|
boolean |
isAutoStartup()
Return whether this Lifecycle component should be started automatically
by the container when the ApplicationContext is refreshed.
|
boolean |
isRunning()
Check whether this component is currently running.
|
private void |
openSystemSession()
Open a "system" session for sending messages from parts of the application
not assoicated with a client STOMP session.
|
void |
setRelayHost(java.lang.String relayHost)
Set the STOMP message broker host.
|
void |
setRelayPort(int relayPort)
Set the STOMP message broker port.
|
void |
setSystemLogin(java.lang.String systemLogin)
Set the login for a "system" TCP connection used to send messages to the STOMP
broker without having a client session (e.g.
|
void |
setSystemPasscode(java.lang.String systemPasscode)
Set the passcode for a "system" TCP connection used to send messages to the STOMP
broker without having a client session (e.g.
|
void |
start()
Start this component.
|
void |
stop()
Stop this component, typically in a synchronous fashion, such that
the component is fully stopped upon return of this method.
|
void |
stop(java.lang.Runnable callback)
Indicates that a Lifecycle component must stop if it is currently running.
|
private static final Log logger
private static final java.lang.String STOMP_RELAY_SYSTEM_SESSION_ID
private final MessageChannel messageChannel
private final java.lang.String[] destinationPrefixes
private java.lang.String relayHost
private int relayPort
private java.lang.String systemLogin
private java.lang.String systemPasscode
private final StompMessageConverter stompMessageConverter
private Environment environment
privatetcpClient
private final java.util.Map<java.lang.String,StompBrokerRelayMessageHandler.RelaySession> relaySessions
private java.lang.Object lifecycleMonitor
private boolean running
public StompBrokerRelayMessageHandler(MessageChannel messageChannel, java.util.Collection<java.lang.String> destinationPrefixes)
messageChannel
- the channel to send messages from the STOMP broker todestinationPrefixes
- the broker supported destination prefixes; destinations
that do not match the given prefix are ignored.public void setRelayHost(java.lang.String relayHost)
public java.lang.String getRelayHost()
public void setRelayPort(int relayPort)
public int getRelayPort()
public void setSystemLogin(java.lang.String systemLogin)
public java.lang.String getSystemLogin()
public void setSystemPasscode(java.lang.String systemPasscode)
public java.lang.String getSystemPasscode()
public java.lang.String[] getDestinationPrefixes()
public boolean isAutoStartup()
SmartLifecycle
isAutoStartup
in interface SmartLifecycle
public int getPhase()
Phased
public boolean isRunning()
Lifecycle
In the case of a container, this will return true
only if all components that apply are currently running.
public void start()
Lifecycle
In the case of a container, this will propagate the start signal to all components that apply.
private void openSystemSession()
public void stop()
Lifecycle
SmartLifecycle
and its stop(Runnable)
variant in cases where asynchronous stop behavior is necessary.
Should not throw an exception if the component isn't started yet.
In the case of a container, this will propagate the stop signal to all components that apply.
stop
in interface Lifecycle
SmartLifecycle.stop(Runnable)
public void stop(java.lang.Runnable callback)
SmartLifecycle
The provided callback is used by the LifecycleProcessor
to support an
ordered, and potentially concurrent, shutdown of all components having a
common shutdown order value. The callback must be executed after
the SmartLifecycle component does indeed stop.
The LifecycleProcessor
will call only this variant of the
stop
method; i.e. Lifecycle.stop()
will not be called for
SmartLifecycle
implementations unless explicitly delegated to within
this method.
stop
in interface SmartLifecycle
public void handleMessage(Message<?> message)
MessageHandler
MessageRejectedException
e.g.
in case of a Selective Consumer. When a consumer tries to handle a
message, but fails to do so, a MessageHandlingException
is
thrown. In the last case it is recommended to treat the message as tainted
and go into an error scenario.
When the handling results in a failure of another message being sent
(e.g. a "reply" message), that failure will trigger a
MessageDeliveryException
.
handleMessage
in interface MessageHandler
message
- the message to be handled
reply related to the handling of the messageprotected boolean checkDestinationPrefix(StompCommand command, java.lang.String destination)