Interface StompSession
- All Known Subinterfaces:
- ConnectionHandlingStompSession
- All Known Implementing Classes:
- DefaultStompSession
public interface StompSession
Represents a STOMP session with operations to send messages,
 create subscriptions and receive messages on those subscriptions.
- Since:
- 4.2
- Author:
- Rossen Stoyanchev
- 
Nested Class SummaryNested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA handle to use to track receipts.static interfaceA handle to use to unsubscribe or to track a receipt.
- 
Method SummaryModifier 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 ofacknowledge(String, boolean)with fullStompHeadersinstead of just amessageId.voidDisconnect the session by sending a DISCONNECT frame.voiddisconnect(StompHeaders headers) Variant ofdisconnect()with headers.Return the id for the session.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 ofsend(String, Object)with fullStompHeadersinstead of just a destination.voidsetAutoReceipt(boolean enabled) When enabled, a receipt header is automatically added to futuresendandsubscribeoperations on this session, which causes the server to return a RECEIPT.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 ofsubscribe(String, StompFrameHandler)with fullStompHeadersinstead of just a destination.
- 
Method Details- 
getSessionIdString getSessionId()Return the id for the session.
- 
isConnectedboolean isConnected()Whether the session is connected.
- 
setAutoReceiptvoid setAutoReceipt(boolean enabled) When 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.
- 
sendSend a message to the specified destination, converting the payload to abyte[]with the help of aMessageConverter.- Parameters:
- destination- the destination to send a message to
- payload- the message payload
- Returns:
- a Receiptable for tracking receipts
 
- 
sendAn overloaded version ofsend(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.- Parameters:
- headers- the message headers
- payload- the message payload
- Returns:
- a Receiptable for tracking receipts
 
- 
subscribeSubscribe to the given destination by sending a SUBSCRIBE frame and handle received messages with the specifiedStompFrameHandler.- Parameters:
- destination- the destination to subscribe to
- handler- the handler for received messages
- Returns:
- a handle to use to unsubscribe and/or track receipts
 
- 
subscribeAn overloaded version ofsubscribe(String, StompFrameHandler)with fullStompHeadersinstead of just a destination.- Parameters:
- headers- the headers for the subscribed message frame
- handler- the handler for received messages
- Returns:
- a handle to use to unsubscribe and/or track receipts
 
- 
acknowledgeSend 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.- Parameters:
- messageId- the id of the message
- consumed- whether the message was consumed or not
- Returns:
- a Receiptable for tracking receipts
- Since:
- 4.3
 
- 
acknowledgeAn overloaded version ofacknowledge(String, boolean)with fullStompHeadersinstead of just amessageId.- Parameters:
- headers- the headers for the ACK or NACK message frame
- consumed- whether the message was consumed or not
- Returns:
- a Receiptable for tracking receipts
- Since:
- 5.0.5
 
- 
disconnectvoid disconnect()Disconnect the session by sending a DISCONNECT frame.
- 
disconnectVariant ofdisconnect()with headers.- Parameters:
- headers- the headers for the disconnect message frame
- Since:
- 5.2.2
 
 
-