类 StompClientSupport
- java.lang.Object
- org.springframework.messaging.simp.stomp.StompClientSupport
public abstract class StompClientSupport extends Object
Base class for STOMP client implementations.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
TcpConnectionHandlerwhose lifecycle methods the subclass must then invoke.In effect,
TcpConnectionHandlerandTcpConnectionare the contracts that any subclass must adapt to while usingStompEncoderandStompDecoderto encode and decode STOMP messages.- 从以下版本开始:
- 4.2
- 作者:
- Rossen Stoyanchev
构造器概要
构造器 构造器 说明 StompClientSupport()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected ConnectionHandlingStompSessioncreateSession(StompHeaders connectHeaders, StompSessionHandler handler)Factory method for create and configure a new session.long[]getDefaultHeartbeat()Return the configured default heart-beat value (nevernull).MessageConvertergetMessageConverter()Return the configuredMessageConverter.longgetReceiptTimeLimit()Return the configured receipt time limit.TaskSchedulergetTaskScheduler()The configured TaskScheduler.booleanisDefaultHeartbeatEnabled()Determine whether heartbeats are enabled.protected StompHeadersprocessConnectHeaders(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(TaskScheduler taskScheduler)Configure a scheduler to use for heartbeats and for receipt tracking.
构造器详细资料
StompClientSupport
public StompClientSupport()
方法详细资料
setMessageConverter
public void setMessageConverter(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.By default,
SimpleMessageConverteris configured.- 参数:
messageConverter- the message converter to use
getMessageConverter
public MessageConverter getMessageConverter()
Return the configuredMessageConverter.
setTaskScheduler
public void setTaskScheduler(@Nullable TaskScheduler taskScheduler)
Configure 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.
getTaskScheduler
@Nullable public TaskScheduler getTaskScheduler()
The configured TaskScheduler.
setDefaultHeartbeat
public 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.
- 参数:
heartbeat- the value for the CONNECT "heart-beat" header- 另请参阅:
- https://stomp.github.io/stomp-specification-1.2.html#Heart-beating
getDefaultHeartbeat
public long[] getDefaultHeartbeat()
Return the configured default heart-beat value (nevernull).
isDefaultHeartbeatEnabled
public boolean isDefaultHeartbeatEnabled()
Determine whether heartbeats are enabled.Returns
falseifdefaultHeartbeatis set to "0,0", andtrueotherwise.
setReceiptTimeLimit
public void setReceiptTimeLimit(long receiptTimeLimit)
Configure the number of milliseconds before a receipt is considered expired.By default set to 15,000 (15 seconds).
getReceiptTimeLimit
public long getReceiptTimeLimit()
Return the configured receipt time limit.
createSession
protected ConnectionHandlingStompSession createSession(@Nullable StompHeaders connectHeaders, StompSessionHandler handler)
Factory method for create and configure a new session.- 参数:
connectHeaders- headers for the STOMP CONNECT framehandler- the handler for the STOMP session- 返回:
- the created session
processConnectHeaders
protected StompHeaders processConnectHeaders(@Nullable StompHeaders connectHeaders)
Further initialize the StompHeaders, for example setting the heart-beat header if necessary.- 参数:
connectHeaders- the headers to modify- 返回:
- the modified headers