Package org.hildan.krossbow.stomp

Types

Link copied to clipboard
open class ConnectionException(    val url: String,     message: String,     cause: Throwable? = null) : Exception

Exception thrown when something went wrong during the connection.

Link copied to clipboard
class ConnectionTimeout(val url: String, timeout: Duration) : ConnectionException

Exception thrown when the websocket connection + STOMP connection takes too much time.

Link copied to clipboard
class LostReceiptException(    val receiptId: String,     val configuredTimeout: Duration,     val frame: StompFrame) : Exception

An exception thrown when a RECEIPT frame was expected from the server, but not received in the configured time limit.

Link copied to clipboard
class MissingHeartBeatException(val expectedPeriod: Duration) : Exception

An exception thrown when expected heart beats are not received.

Link copied to clipboard
class StompClient(webSocketClient: WebSocketClient, config: StompConfig)

A STOMP 1.2 client based on web sockets. A custom web socket implementation can be passed in as a constructor parameter.

Link copied to clipboard
class StompConnectionException(val host: String?, cause: Throwable? = null) : ConnectionException

Exception thrown when the connection attempt failed at STOMP protocol level.

Link copied to clipboard
class StompErrorFrameReceived(val frame: StompFrame.Error) : Exception

An exception thrown when a STOMP ERROR frame is received. It is usually thrown through subscription channels.

Link copied to clipboard
data class StompReceipt(val id: String)
Link copied to clipboard
interface StompSession

A coroutine-based STOMP session. This interface defines interactions with a STOMP server.

Link copied to clipboard
class WebSocketClosedUnexpectedly(val code: Int, val reason: String?) : Exception

An exception thrown when the underlying websocket connection was closed at an inappropriate time.

Link copied to clipboard
open class WebSocketConnectionException(    val url: String,     message: String = "Failed to connect at web socket level to ",     cause: Throwable? = null) : ConnectionException

Exception thrown when the connection attempt failed at web socket level.

Functions

Link copied to clipboard
suspend fun StompSession.sendBinary(destination: String, body: ByteArray?): StompReceipt?

Sends a SEND frame to the server at the given destination with the given binary body.

Link copied to clipboard
suspend fun StompSession.sendEmptyMsg(destination: String): StompReceipt?

Sends a SEND frame to the server at the given destination without body.

Link copied to clipboard
suspend fun StompSession.sendText(destination: String, body: String?): StompReceipt?

Sends a SEND frame to the server at the given destination with the given textual body.

Link copied to clipboard
suspend fun WebSocketConnection.stomp(    config: StompConfig,     host: String? = this.host,     login: String? = null,     passcode: String? = null,     customHeaders: Map<String, String> = emptyMap(),     sessionCoroutineContext: CoroutineContext = EmptyCoroutineContext): StompSession

Establishes a STOMP session over an existing WebSocketConnection.

Link copied to clipboard
suspend fun StompSession.subscribe(destination: String): Flow<StompFrame.Message>

Subscribes and returns a Flow of MESSAGE frames that unsubscribes automatically when the collector is done or cancelled. The returned flow can be collected only once.

Link copied to clipboard
suspend fun StompSession.subscribeBinary(destination: String): Flow<ByteArray>

Subscribes and returns a Flow of binary message bodies that unsubscribes automatically when the collector is done or cancelled. The returned flow can be collected only once.

Link copied to clipboard
suspend fun StompSession.subscribeText(destination: String): Flow<String>

Subscribes and returns a Flow of text message bodies that unsubscribes automatically when the collector is done or cancelled. The returned flow can be collected only once.

Link copied to clipboard
inline suspend fun <S : StompSession, R> S.use(block: (S) -> R): R

Executes the given block on this StompSession, and disconnects from the session whether the block terminated normally or exceptionally.

Link copied to clipboard
suspend fun <T> StompSession.withTransaction(block: suspend StompSession.(transactionId: String) -> T): T

Executes the given block as part of a transaction.