public abstract class StompClientSupport
extends java.lang.Object
Subclasses can connect over WebSocket or TCP using any library. When creating
a new connection, a subclass can create an instance of @link DefaultStompSession}
which extends TcpConnectionHandler
whose lifecycle methods the subclass must then invoke.
In effect, TcpConnectionHandler
and TcpConnection
are the
contracts that any subclass must adapt to while using StompEncoder
and StompDecoder
to encode and decode STOMP messages.
Constructor and Description |
---|
StompClientSupport() |
Modifier and Type | Method and Description |
---|---|
protected ConnectionHandlingStompSession |
createSession(StompHeaders connectHeaders,
StompSessionHandler handler)
Factory method for create and configure a new session.
|
long[] |
getDefaultHeartbeat()
Return the configured default heart-beat value (never
null ). |
MessageConverter |
getMessageConverter()
Return the configured
MessageConverter . |
long |
getReceiptTimeLimit()
Return the configured receipt time limit.
|
TaskScheduler |
getTaskScheduler()
The configured TaskScheduler.
|
boolean |
isDefaultHeartbeatEnabled()
Determine whether heartbeats are enabled.
|
protected StompHeaders |
processConnectHeaders(StompHeaders connectHeaders)
Further initialize the StompHeaders, for example setting the heart-beat
header if necessary.
|
void |
setDefaultHeartbeat(long[] heartbeat)
Configure the default value for the "heart-beat" header of the STOMP
CONNECT frame.
|
void |
setMessageConverter(MessageConverter messageConverter)
Set the
MessageConverter to use to convert the payload of incoming
and outgoing messages to and from byte[] based on object type
and the "content-type" header. |
void |
setReceiptTimeLimit(long receiptTimeLimit)
Configure the number of milliseconds before a receipt is considered expired.
|
void |
setTaskScheduler(TaskScheduler taskScheduler)
Configure a scheduler to use for heartbeats and for receipt tracking.
|
protected Log logger
public void setMessageConverter(MessageConverter messageConverter)
MessageConverter
to use to convert the payload of incoming
and outgoing messages to and from byte[]
based on object type
and the "content-type" header.
By default, SimpleMessageConverter
is configured.
messageConverter
- the message converter to usepublic MessageConverter getMessageConverter()
MessageConverter
.public void setTaskScheduler(TaskScheduler taskScheduler)
Note: Some transports have built-in support to work with heartbeats and therefore do not require a TaskScheduler. Receipts however, if needed, do require a TaskScheduler to be configured.
By default, this is not set.
public TaskScheduler getTaskScheduler()
public void setDefaultHeartbeat(long[] heartbeat)
By default this is set to "10000,10000" but subclasses may override that default and for example set it to "0,0" if they require a TaskScheduler to be configured first.
heartbeat
- the value for the CONNECT "heart-beat" headerpublic long[] getDefaultHeartbeat()
null
).public boolean isDefaultHeartbeatEnabled()
Returns false
if defaultHeartbeat
is set to "0,0", and true
otherwise.
public void setReceiptTimeLimit(long receiptTimeLimit)
By default set to 15,000 (15 seconds).
public long getReceiptTimeLimit()
protected ConnectionHandlingStompSession createSession(StompHeaders connectHeaders, StompSessionHandler handler)
connectHeaders
- headers for the STOMP CONNECT framehandler
- the handler for the STOMP sessionprotected StompHeaders processConnectHeaders(StompHeaders connectHeaders)
connectHeaders
- the headers to modify