Class DefaultStompSession
java.lang.Object
org.springframework.messaging.simp.stomp.DefaultStompSession
- All Implemented Interfaces:
 ConnectionHandlingStompSession,StompSession,StompTcpConnectionHandler<byte[]>,TcpConnectionHandler<byte[]>
Default implementation of 
ConnectionHandlingStompSession.- Since:
 - 4.2
 - Author:
 - Rossen Stoyanchev
 
- 
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.messaging.simp.stomp.StompSession
StompSession.Receiptable, StompSession.Subscription - 
Field Summary
Fields - 
Constructor Summary
ConstructorsConstructorDescriptionDefaultStompSession(StompSessionHandler sessionHandler, StompHeaders connectHeaders) Create a new session. - 
Method Summary
Modifier and TypeMethodDescriptionacknowledge(String messageId, boolean consumed) Send an acknowledgement whether a message was consumed or not resulting in an ACK or NACK frame respectively.acknowledge(StompHeaders headers, boolean consumed) An overloaded version ofStompSession.acknowledge(String, boolean)with fullStompHeadersinstead of just amessageId.voidafterConnected(TcpConnection<byte[]> connection) Invoked after a connection is successfully established.voidInvoked on failure to connect.voidInvoked after the connection is closed.voidDisconnect the session by sending a DISCONNECT frame.voiddisconnect(StompHeaders headers) Variant ofStompSession.disconnect()with headers.Return the headers that will be sent in the STOMP CONNECT frame.Return the configuredMessageConverter.longReturn the configured time limit before a receipt expires.Return a future that will complete when the session is ready for use.Return the configured session handler.Return the id for the session.Return the configured TaskScheduler to use for receipt tracking.voidHandle a failure on the connection.voidhandleMessage(Message<byte[]> message) Handle a message received from the remote host.booleanWhether receipt headers should be automatically added.booleanWhether the session is connected.Send a message to the specified destination, converting the payload to abyte[]with the help of aMessageConverter.send(StompHeaders headers, Object payload) An overloaded version ofStompSession.send(String, Object)with fullStompHeadersinstead of just a destination.voidsetAutoReceipt(boolean autoReceiptEnabled) When enabled, a receipt header is automatically added to futuresendandsubscribeoperations on this session, which causes the server to return a RECEIPT.voidsetMessageConverter(MessageConverter messageConverter) Set theMessageConverterto use to convert the payload of incoming and outgoing messages to and frombyte[]based on object type, or expected object type, and the "content-type" header.voidsetReceiptTimeLimit(long receiptTimeLimit) Configure the time in milliseconds before a receipt expires.voidsetTaskScheduler(TaskScheduler taskScheduler) Configure the TaskScheduler to use for receipt tracking.subscribe(String destination, StompFrameHandler handler) Subscribe to the given destination by sending a SUBSCRIBE frame and handle received messages with the specifiedStompFrameHandler.subscribe(StompHeaders headers, StompFrameHandler handler) An overloaded version ofStompSession.subscribe(String, StompFrameHandler)with fullStompHeadersinstead of just a destination.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.messaging.simp.stomp.ConnectionHandlingStompSession
getSessionFuture 
- 
Field Details
- 
EMPTY_PAYLOAD
public static final byte[] EMPTY_PAYLOADAn empty payload. 
 - 
 - 
Constructor Details
- 
DefaultStompSession
Create a new session.- Parameters:
 sessionHandler- the application handler for the sessionconnectHeaders- headers for the STOMP CONNECT frame
 
 - 
 - 
Method Details
- 
getSessionId
Description copied from interface:StompSessionReturn the id for the session.- Specified by:
 getSessionIdin interfaceStompSession- Specified by:
 getSessionIdin interfaceStompTcpConnectionHandler<byte[]>
 - 
getConnectHeaders
Description copied from interface:StompTcpConnectionHandlerReturn the headers that will be sent in the STOMP CONNECT frame.- Specified by:
 getConnectHeadersin interfaceStompTcpConnectionHandler<byte[]>
 - 
getSessionHandler
Return the configured session handler. - 
getSession
Description copied from interface:ConnectionHandlingStompSessionReturn a future that will complete when the session is ready for use.- Specified by:
 getSessionin interfaceConnectionHandlingStompSession
 - 
setMessageConverter
Set theMessageConverterto use to convert the payload of incoming and outgoing messages to and frombyte[]based on object type, or expected object type, and the "content-type" header.By default,
SimpleMessageConverteris configured.- Parameters:
 messageConverter- the message converter to use
 - 
getMessageConverter
Return the configuredMessageConverter. - 
setTaskScheduler
Configure the TaskScheduler to use for receipt tracking. - 
getTaskScheduler
Return the configured TaskScheduler to use for receipt tracking. - 
setReceiptTimeLimit
public void setReceiptTimeLimit(long receiptTimeLimit) Configure the time in milliseconds before a receipt expires.By default set to 15,000 (15 seconds).
 - 
getReceiptTimeLimit
public long getReceiptTimeLimit()Return the configured time limit before a receipt expires. - 
setAutoReceipt
public void setAutoReceipt(boolean autoReceiptEnabled) Description copied from interface:StompSessionWhen enabled, a receipt header is automatically added to futuresendandsubscribeoperations on this session, which causes the server to return a RECEIPT. An application can then use theReceiptablereturned from the operation to track the receipt.A receipt header can also be added manually through the overloaded methods that accept
StompHeaders.- Specified by:
 setAutoReceiptin interfaceStompSession
 - 
isAutoReceiptEnabled
public boolean isAutoReceiptEnabled()Whether receipt headers should be automatically added. - 
isConnected
public boolean isConnected()Description copied from interface:StompSessionWhether the session is connected.- Specified by:
 isConnectedin interfaceStompSession
 - 
send
Description copied from interface:StompSessionSend a message to the specified destination, converting the payload to abyte[]with the help of aMessageConverter.- Specified by:
 sendin interfaceStompSession- Parameters:
 destination- the destination to send a message topayload- the message payload- Returns:
 - a Receiptable for tracking receipts
 
 - 
send
Description copied from interface:StompSessionAn overloaded version ofStompSession.send(String, Object)with fullStompHeadersinstead of just a destination. The headers must contain a destination and may also have other headers such as "content-type" or custom headers for the broker to propagate to subscribers, or broker-specific, non-standard headers.- Specified by:
 sendin interfaceStompSession- Parameters:
 headers- the message headerspayload- the message payload- Returns:
 - a Receiptable for tracking receipts
 
 - 
subscribe
Description copied from interface:StompSessionSubscribe to the given destination by sending a SUBSCRIBE frame and handle received messages with the specifiedStompFrameHandler.- Specified by:
 subscribein interfaceStompSession- Parameters:
 destination- the destination to subscribe tohandler- the handler for received messages- Returns:
 - a handle to use to unsubscribe and/or track receipts
 
 - 
subscribe
Description copied from interface:StompSessionAn overloaded version ofStompSession.subscribe(String, StompFrameHandler)with fullStompHeadersinstead of just a destination.- Specified by:
 subscribein interfaceStompSession- Parameters:
 headers- the headers for the subscribed message framehandler- the handler for received messages- Returns:
 - a handle to use to unsubscribe and/or track receipts
 
 - 
acknowledge
Description copied from interface:StompSessionSend an acknowledgement whether a message was consumed or not resulting in an ACK or NACK frame respectively.Note: to use this when subscribing you must set the
ackheader to "client" or "client-individual" in order ot use this.- Specified by:
 acknowledgein interfaceStompSession- Parameters:
 messageId- the id of the messageconsumed- whether the message was consumed or not- Returns:
 - a Receiptable for tracking receipts
 
 - 
acknowledge
Description copied from interface:StompSessionAn overloaded version ofStompSession.acknowledge(String, boolean)with fullStompHeadersinstead of just amessageId.- Specified by:
 acknowledgein interfaceStompSession- Parameters:
 headers- the headers for the ACK or NACK message frameconsumed- whether the message was consumed or not- Returns:
 - a Receiptable for tracking receipts
 
 - 
disconnect
public void disconnect()Description copied from interface:StompSessionDisconnect the session by sending a DISCONNECT frame.- Specified by:
 disconnectin interfaceStompSession
 - 
disconnect
Description copied from interface:StompSessionVariant ofStompSession.disconnect()with headers.- Specified by:
 disconnectin interfaceStompSession- Parameters:
 headers- the headers for the disconnect message frame
 - 
afterConnected
Description copied from interface:TcpConnectionHandlerInvoked after a connection is successfully established.- Specified by:
 afterConnectedin interfaceTcpConnectionHandler<byte[]>- Parameters:
 connection- the connection
 - 
afterConnectFailure
Description copied from interface:TcpConnectionHandlerInvoked on failure to connect.- Specified by:
 afterConnectFailurein interfaceTcpConnectionHandler<byte[]>- Parameters:
 ex- the exception
 - 
handleMessage
Description copied from interface:TcpConnectionHandlerHandle a message received from the remote host.- Specified by:
 handleMessagein interfaceTcpConnectionHandler<byte[]>- Parameters:
 message- the message
 - 
handleFailure
Description copied from interface:TcpConnectionHandlerHandle a failure on the connection.- Specified by:
 handleFailurein interfaceTcpConnectionHandler<byte[]>- Parameters:
 ex- the exception
 - 
afterConnectionClosed
public void afterConnectionClosed()Description copied from interface:TcpConnectionHandlerInvoked after the connection is closed.- Specified by:
 afterConnectionClosedin interfaceTcpConnectionHandler<byte[]>
 
 -