subscribe

abstract suspend fun <T : Any> subscribe(headers: StompSubscribeHeaders, clazz: KClass<T>): Flow<T>

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

The received MESSAGE frames are converted into instances of T, but the exact conversion is implementation-dependent. Message frames without a body MAY be skipped or result in an exception depending on the implementation.

See the general StompSession documentation for more details about subscription flows and receipts.

Sources

Link copied to clipboard