Top Description Inners Fields Constructors Methods
org.springframework.messaging.simp.stomp

public Class DefaultStompSession

extends Object
implements ConnectionHandlingStompSession
Class Inheritance
All Implemented Interfaces
org.springframework.messaging.simp.stomp.ConnectionHandlingStompSession, org.springframework.messaging.simp.stomp.StompTcpConnectionHandler, org.springframework.messaging.tcp.TcpConnectionHandler, org.springframework.messaging.simp.stomp.StompSession
Imports
java.lang.reflect.Type, java.time.Instant, java.util.ArrayList, .List, .Map, java.util.concurrent.CompletableFuture, .ConcurrentHashMap, .ExecutionException, .ScheduledFuture, .TimeUnit, java.util.concurrent.atomic.AtomicInteger, java.util.function.Consumer, org.apache.commons.logging.Log, org.springframework.core.ResolvableType, org.springframework.lang.Nullable, org.springframework.messaging.Message, .MessageDeliveryException, org.springframework.messaging.converter.MessageConversionException, .MessageConverter, .SimpleMessageConverter, org.springframework.messaging.simp.SimpLogging, org.springframework.messaging.support.MessageBuilder, .MessageHeaderAccessor, org.springframework.messaging.tcp.TcpConnection, org.springframework.scheduling.TaskScheduler, org.springframework.util.AlternativeJdkIdGenerator, .Assert, .IdGenerator, .ObjectUtils, .StringUtils

Default implementation of ConnectionHandlingStompSession.
Author
Rossen Stoyanchev
Since
4.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private class
private class
private class

Field Summary

Modifier and TypeField and Description
private volatile boolean
private volatile boolean
private final StompHeaders
private volatile TcpConnection<byte[]>
private MessageConverter
public static final byte[]
EMPTY_PAYLOAD

An empty payload.

private static final Message<byte[]>
private static final long
private static final IdGenerator
private static final Log
private final Map<String, DefaultStompSession.ReceiptHandler>
private final AtomicInteger
private long
private final CompletableFuture<StompSession>
private final StompSessionHandler
private final String
private final AtomicInteger
private final Map<String, DefaultStompSession.DefaultSubscription>
private TaskScheduler
private volatile String

Constructor Summary

AccessConstructor and Description
public
DefaultStompSession(StompSessionHandler
the application handler for the session
sessionHandler
,
StompHeaders
headers for the STOMP CONNECT frame
connectHeaders
)

Create a new session.

Method Summary

Modifier and TypeMethod and Description
public StompSession.Receiptable
acknowledge(String
the id of the message
messageId
,
boolean
whether the message was consumed or not
consumed
)

Implements org.springframework.messaging.simp.stomp.StompSession.acknowledge.

Send an acknowledgement whether a message was consumed or not resulting in an ACK or NACK frame respectively.

public StompSession.Receiptable
acknowledge(StompHeaders
the headers for the ACK or NACK message frame
headers
,
boolean
whether the message was consumed or not
consumed
)

Implements org.springframework.messaging.simp.stomp.StompSession.acknowledge.

An overloaded version of acknowledge(String, boolean) with full StompHeaders instead of just a messageId.

public void
afterConnected(TcpConnection<byte[]>
the connection
connection
)

Implements org.springframework.messaging.tcp.TcpConnectionHandler.afterConnected.

Invoked after a connection is successfully established.

public void
public void
private String
private StompHeaderAccessor
private Message<byte[]>
public void
disconnect()

Implements org.springframework.messaging.simp.stomp.StompSession.disconnect.

Disconnect the session by sending a DISCONNECT frame.

public void
disconnect(StompHeaders
the headers for the disconnect message frame
headers
)

Implements org.springframework.messaging.simp.stomp.StompSession.disconnect.

Variant of disconnect() with headers.

private void
execute(Message<byte[]> message)

public StompHeaderAccessor
getConnectHeaders()

Implements org.springframework.messaging.simp.stomp.StompTcpConnectionHandler.getConnectHeaders.

Return the headers that will be sent in the STOMP CONNECT frame.

public MessageConverter
getMessageConverter()

Return the configured MessageConverter.

public long
getReceiptTimeLimit()

Return the configured time limit before a receipt expires.

public CompletableFuture<StompSession>
getSession()

Implements org.springframework.messaging.simp.stomp.ConnectionHandlingStompSession.getSession.

Return a future that will complete when the session is ready for use.

public StompSessionHandler
getSessionHandler()

Return the configured session handler.

public String
public TaskScheduler
getTaskScheduler()

Return the configured TaskScheduler to use for receipt tracking.

public void
handleFailure(Throwable
the exception
ex
)

Implements org.springframework.messaging.tcp.TcpConnectionHandler.handleFailure.

Handle a failure on the connection.

public void
handleMessage(Message<byte[]>
the message
message
)

Implements org.springframework.messaging.tcp.TcpConnectionHandler.handleMessage.

Handle a message received from the remote host.

private void
initHeartbeatTasks(StompHeaders connectedHeaders)

private void
invokeHandler(StompFrameHandler handler, Message<byte[]> message, StompHeaders headers)

public boolean
isAutoReceiptEnabled()

Whether receipt headers should be automatically added.

public boolean
private void
public StompSession.Receiptable
send(String
the destination to send a message to
destination
,
Object
the message payload
payload
)

Implements org.springframework.messaging.simp.stomp.StompSession.send.

Send a message to the specified destination, converting the payload to a byte[] with the help of a MessageConverter.

public StompSession.Receiptable
send(StompHeaders
the message headers
headers
,
Object
the message payload
payload
)

Implements org.springframework.messaging.simp.stomp.StompSession.send.

An overloaded version of send(String, Object) with full StompHeaders instead of just a destination.

public void
setAutoReceipt(boolean autoReceiptEnabled)

Implements org.springframework.messaging.simp.stomp.StompSession.setAutoReceipt.

When enabled, a receipt header is automatically added to future send and subscribe operations on this session, which causes the server to return a RECEIPT.

public void
setMessageConverter(MessageConverter
the message converter to use
messageConverter
)

Set the MessageConverter to use to convert the payload of incoming and outgoing messages to and from byte[] based on object type, or expected object type, and the "content-type" header.

public void
setReceiptTimeLimit(long receiptTimeLimit)

Configure the time in milliseconds before a receipt expires.

public void
setTaskScheduler(TaskScheduler taskScheduler)

Configure the TaskScheduler to use for receipt tracking.

public StompSession.Subscription
subscribe(String
the destination to subscribe to
destination
,
StompFrameHandler
the handler for received messages
handler
)

Implements org.springframework.messaging.simp.stomp.StompSession.subscribe.

Subscribe to the given destination by sending a SUBSCRIBE frame and handle received messages with the specified StompFrameHandler.

public StompSession.Subscription
subscribe(StompHeaders
the headers for the subscribed message frame
headers
,
StompFrameHandler
the handler for received messages
handler
)

Implements org.springframework.messaging.simp.stomp.StompSession.subscribe.

An overloaded version of subscribe(String, StompFrameHandler) with full StompHeaders instead of just a destination.

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait