接口 StompSession
- 所有已知子接口:
ConnectionHandlingStompSession
- 所有已知实现类:
DefaultStompSession
public interface StompSession
Represents a STOMP session with operations to send messages, create subscriptions and receive messages on those subscriptions.- 从以下版本开始:
- 4.2
- 作者:
- Rossen Stoyanchev
嵌套类概要
嵌套类 修饰符和类型 接口 说明 static interface
StompSession.Receiptable
A handle to use to track receipts.static interface
StompSession.Subscription
A handle to use to unsubscribe or to track a receipt.
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 StompSession.Receiptable
acknowledge(String messageId, boolean consumed)
Send an acknowledgement whether a message was consumed or not resulting in an ACK or NACK frame respectively.void
disconnect()
Disconnect the session by sending a DISCONNECT frame.String
getSessionId()
Return the id for the session.boolean
isConnected()
Whether the session is connected.StompSession.Receiptable
send(String destination, Object payload)
Send a message to the specified destination, converting the payload to abyte[]
with the help of aMessageConverter
.StompSession.Receiptable
send(StompHeaders headers, Object payload)
An overloaded version ofsend(String, Object)
with fullStompHeaders
instead of just a destination.void
setAutoReceipt(boolean enabled)
When enabled, a receipt header is automatically added to futuresend
andsubscribe
operations on this session, which causes the server to return a RECEIPT.StompSession.Subscription
subscribe(String destination, StompFrameHandler handler)
Subscribe to the given destination by sending a SUBSCRIBE frame and handle received messages with the specifiedStompFrameHandler
.StompSession.Subscription
subscribe(StompHeaders headers, StompFrameHandler handler)
An overloaded version ofsubscribe(String, StompFrameHandler)
with fullStompHeaders
instead of just a destination.
方法详细资料
getSessionId
String getSessionId()
Return the id for the session.
isConnected
boolean isConnected()
Whether the session is connected.
setAutoReceipt
void setAutoReceipt(boolean enabled)
When enabled, a receipt header is automatically added to futuresend
andsubscribe
operations on this session, which causes the server to return a RECEIPT. An application can then use theReceiptable
returned from the operation to track the receipt.A receipt header can also be added manually through the overloaded methods that accept
StompHeaders
.
send
StompSession.Receiptable send(String destination, Object payload)
Send a message to the specified destination, converting the payload to abyte[]
with the help of aMessageConverter
.- 参数:
destination
- the destination to send a message topayload
- the message payload- 返回:
- a Receiptable for tracking receipts
send
StompSession.Receiptable send(StompHeaders headers, Object payload)
An overloaded version ofsend(String, Object)
with fullStompHeaders
instead 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.- 参数:
headers
- the message headerspayload
- the message payload- 返回:
- a Receiptable for tracking receipts
subscribe
StompSession.Subscription subscribe(String destination, StompFrameHandler handler)
Subscribe to the given destination by sending a SUBSCRIBE frame and handle received messages with the specifiedStompFrameHandler
.- 参数:
destination
- the destination to subscribe tohandler
- the handler for received messages- 返回:
- a handle to use to unsubscribe and/or track receipts
subscribe
StompSession.Subscription subscribe(StompHeaders headers, StompFrameHandler handler)
An overloaded version ofsubscribe(String, StompFrameHandler)
with fullStompHeaders
instead of just a destination.- 参数:
headers
- the headers for the subscribe message framehandler
- the handler for received messages- 返回:
- a handle to use to unsubscribe and/or track receipts
acknowledge
StompSession.Receiptable acknowledge(String messageId, boolean consumed)
Send 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
ack
header to "client" or "client-individual" in order ot use this.- 参数:
messageId
- the id of the messageconsumed
- whether the message was consumed or not- 返回:
- a Receiptable for tracking receipts
- 从以下版本开始:
- 4.3
disconnect
void disconnect()
Disconnect the session by sending a DISCONNECT frame.