subscribe

inline suspend fun <T> TypedStompSession.subscribe(destination: String): Flow<T>(source)

Subscribes to the given destination 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 to instances of T, but the exact conversion is implementation-dependent. In particular, message frames without a body can be processed in different ways depending on the implementation. Implementations can choose to throw an exception, skip such frames, or convert them to null (if T is nullable).

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