Class StompClientSupport
- Direct Known Subclasses:
- ReactorNettyTcpStompClient, WebSocketStompClient
Subclasses can connect over WebSocket or TCP using any library. When creating
a new connection, a subclass can create an instance of DefaultStompSession
which implements 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.
- Since:
- 4.2
- Author:
- Rossen Stoyanchev
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected ConnectionHandlingStompSessioncreateSession(@Nullable StompHeaders connectHeaders, StompSessionHandler handler) Factory method for create and configure a new session.long[]Return the configured default heart-beat value (nevernull).Return the configuredMessageConverter.longReturn the configured receipt time limit.The configured TaskScheduler.booleanDetermine whether heartbeats are enabled.protected StompHeadersprocessConnectHeaders(@Nullable StompHeaders connectHeaders) Further initialize the StompHeaders, for example setting the heart-beat header if necessary.voidsetDefaultHeartbeat(long[] heartbeat) Configure the default value for the "heart-beat" header of the STOMP CONNECT frame.voidsetMessageConverter(MessageConverter messageConverter) Set theMessageConverterto use to convert the payload of incoming and outgoing messages to and frombyte[]based on object type and the "content-type" header.voidsetReceiptTimeLimit(long receiptTimeLimit) Configure the number of milliseconds before a receipt is considered expired.voidsetTaskScheduler(@Nullable TaskScheduler taskScheduler) Configure a scheduler to use for heartbeats and for receipt tracking.
- 
Constructor Details- 
StompClientSupportpublic StompClientSupport()
 
- 
- 
Method Details- 
setMessageConverterSet theMessageConverterto use to convert the payload of incoming and outgoing messages to and frombyte[]based on object type and the "content-type" header.By default, SimpleMessageConverteris configured.- Parameters:
- messageConverter- the message converter to use
 
- 
getMessageConverterReturn the configuredMessageConverter.
- 
setTaskSchedulerConfigure a scheduler to use for heartbeats and for receipt tracking.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. 
- 
getTaskSchedulerThe configured TaskScheduler.
- 
setDefaultHeartbeatpublic void setDefaultHeartbeat(long[] heartbeat) Configure the default value for the "heart-beat" header of the STOMP CONNECT frame. The first number represents how often the client will write or send a heart-beat. The second is how often the server should write. A value of 0 means no heart-beats.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. Note: that a heartbeat is sent only in case of inactivity, i.e. when no other messages are sent. This can present a challenge when using an external broker since messages with a non-broker destination represent activity but aren't actually forwarded to the broker. In that case you can configure a `TaskScheduler` through the StompBrokerRelayRegistrationwhich ensures a heartbeat is forwarded to the broker also when only messages with a non-broker destination are sent.- Parameters:
- heartbeat- the value for the CONNECT "heart-beat" header
- See Also:
 
- 
getDefaultHeartbeatpublic long[] getDefaultHeartbeat()Return the configured default heart-beat value (nevernull).
- 
isDefaultHeartbeatEnabledpublic boolean isDefaultHeartbeatEnabled()Determine whether heartbeats are enabled.Returns falseifdefaultHeartbeatis set to "0,0", andtrueotherwise.
- 
setReceiptTimeLimitpublic void setReceiptTimeLimit(long receiptTimeLimit) Configure the number of milliseconds before a receipt is considered expired.By default set to 15,000 (15 seconds). 
- 
getReceiptTimeLimitpublic long getReceiptTimeLimit()Return the configured receipt time limit.
- 
createSessionprotected ConnectionHandlingStompSession createSession(@Nullable StompHeaders connectHeaders, StompSessionHandler handler) Factory method for create and configure a new session.- Parameters:
- connectHeaders- headers for the STOMP CONNECT frame
- handler- the handler for the STOMP session
- Returns:
- the created session
 
- 
processConnectHeadersFurther initialize the StompHeaders, for example setting the heart-beat header if necessary.- Parameters:
- connectHeaders- the headers to modify
- Returns:
- the modified headers
 
 
-